An instance of an js input box that uses regular expressions to validate input

  • 2021-07-21 05:54:59
  • OfStack

js input box input verification


/* User name format judgment-user name can only be underlined, numeric, alphanumeric or Chinese length not exceeding 10 Characters */

function checkUserName(str) {
var reg = /^[_0-9a-zA-Z\u4e00-\u9fa5]{1,10}$/;
return reg.test(str);
} 


Related articles: