我正在使用jquery.validationengine.en.js来(自定义)验证我的表单字段。对于一个字段,我使用两个自定义验证。我不想同时显示字段的验证消息。它一次只能显示一个味精。怎么做?结合两个正则表达式
请在下面的代码找到 注意:allzero也被其他一些领域使用。
"phone": {
"regex": /^[0-9]{8,15}$/,
"alertText": "* Invalid phone number"
},
"allzero": {
"regex": /([^((\+)*(0*))])/,
"alertText": "* Invalid number"
},
HTML代码:
<input type="text" name="phone" id="phone" class="textBox textNormal validate[maxSize[30],custom[onlyNumberSp],custom[phonenumber],custom[allzero]]" onfocus="jQuery('#adduserform').validationEngine('attach',{Overflown:false})">
<input type="text" name="mobile" id="mobile" class="textBox textNormal validate[maxSize[30],custom[onlyNumberSp],custom[mobile],custom[allzero]]" value="" onfocus="jQuery('#adduserform').validationEngine('attach',{Overflown:false})">
你能表现出一定的代码?具体来说,两个验证规则的定义是什么? –
添加代码。请检查 – Nila
如果您的第一个正则表达式只允许数字,为什么第二个正则表达式允许任意数量的前导加号?无论如何,第二个正则表达式很糟糕 - 大概你的意思是类似'/^\ +?0 * $ /'? – tripleee