【发布时间】:2011-02-11 07:17:01
【问题描述】:
我有一个用于检查数字并允许“-”(连字符)文本字段的正则表达式。
var regex = /^\d+-\d{1,2}$/; //Checks "digits-digit(s,1 or 2)"
这适用于常规 HTML 文本字段。但是如果我想要一个 Ext Js TextField 我必须执行以下代码
Ext js TextField 并称为 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 '-'
请帮助我更改我的 VType 以使其正常工作并进行正则表达式检查。
【问题讨论】:
标签: javascript regex validation extjs