更新时间:2023-11-29 12:11:16
验证本身不工作(当您在其中输入无效内容时,该字段不会被下划线)或者您是否缺少错误 - 工具提示?在后一种情况下,添加到代码中的某个地方:
Ext.QuickTips.init();
否则,工具提示不会出现。
I have a regular expression for checking numbers and allowing "-" (Hyphen) Text Field.
var regex = /^\d+-\d{1,2}$/; //Checks "digits-digit(s,1 or 2)"
This works ok for regular HTML text field. But if I want a Ext Js TextField I have to do the below code
Ext js TextField and called a VType
var <portlet:namespace/>issueNoField = new Ext.form.TextField({
fieldLabel: 'Issue No',
width: 120,
valueField:'IssNo',
vtype: 'hyphen'
});
Ext.apply(Ext.form.VTypes, {
hyphenText : "Only numbers and hyphen.",
hyphenMask:/[0-9-]/,
hyphenRe: /^\d+-\d{1,2}$/, //This is the check
hyphen:function(x){return this.hyphenRe.test(x);} //Am i missing a numericHyMask: here ??
});
Is hyphenRe: /^\d+-\d{1,2}$/, is correct or
is hyphenRe: /^\d+-[\d{1,2}]$/, is correct as I want 1 or 2 digits after '-'
Please help me change my VTypes to work properly and do that regex check.
Works fine for me. Is the validation itself not working (the field doesn't get underlined when you type invalid stuff in it) or are you missing the error-tooltip? On the latter case add somewhere in your code:
Ext.QuickTips.init();
Otherwise the tooltips wont appear.