Jquery验证:仅允许使用字母和空格 [英] Jquery Validation: allow only alphabets and spaces
本文介绍了Jquery验证:仅允许使用字母和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的验证仅接受字母表。我也想要允许空格。
My validation accepts only alphabets . i want allow spaces as well .
$.validator.addMethod("alpha", function(value, element) {
return this.optional(element) || value == value.match(/^[a-zA-Z]+$/);
});
这里需要做些什么改变?
what change need to be done here ?
推荐答案
而不是以下正则表达式:
Instead of the below regex:
/^[a-zA-Z]+$/
使用此:
/^[a-zA-Z\s]+$/
这也将占用空间。
这篇关于Jquery验证:仅允许使用字母和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文