我有一个表单,其中包含四个文本框手机,phone1,phone2&分机。为了验证,我使用了jquery validate.js。它工作正常,但有一个问题,它允许无效数字也像000-000-0000或001-000-0000
以下是我的验证脚本:
$params['rules'][$phone] = {"required": true,"minlength": 3,"digits":true };
$params['messages'][$phone] = {"required":"<div class='error-message'>*This is required </div> <div class='error-arrow'></div> ",
"minlength":"<div class='error-message'>* Numbers should be 3 digits</div> <div class='error-arrow'></div>","digits":" <div class='error-message'>* Numbers only</div> <div class='error-arrow'></div> "};
$params['rules'][$phone2] = {"required": true,"minlength": 3,"digits":true };
$params['messages'][$phone2] = {"required":"<div class='error-message'>* This is required</div> <div class='error-arrow'></div> ",
"minlength":"<div class='error-message'>* Numbers should be 3 digits</div> <div class='error-arrow'></div>",
"digits":" <div class='error-message'>* Numbers only</div> <div class='error-arrow'></div> "};