且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过JavaScript正则表达式验证输入

更新时间:2022-11-12 09:24:05

You can use javascript test() method to validate name field. The test() method tests for a match in a string.

/^[A-Za-z\s]+$/.test(x) //returns true if matched, vaidates for a-z and A-Z and white space

or

/^[A-Za-z ]+$/.test(x)