The syntax of regular expressions is convenient for program processing, but is not actually a regular expression that can be used directly for filtering. Common regular expression pattern for filtering white-space characters
function Isnumber (handle) {
var pattern =/^ (d) {1,16}$/;
if (!pattern.exec (Handle.value)) {
Handle.value= '
Return "must enter a number!";}
return true;
}
Determine if it is a user account
function Isuserid (handle) {
var pattern =/^ (d|w) {3,14}$/;
if (!pattern.exec (handle.value)) return "must enter the number <br> and the length should be greater than or equal to 3 bits less than or equal to 14 bits!";
return true;
}
To determine whether the user name can be a letter or Chinese
function Isusername (handle) {
var pattern =/^[a-za-zu4e00-u9fa5]{2,50}$/;
if (!pattern.exec (handle.value)) return "must be Chinese letter or number <br> and the length should be greater than or equal to 2 bits or less or 50 bits!"
return true;
}
Determine whether it is a name: can be alphanumeric Chinese-_
function Isname (handle) {
var pattern =/^[a-za-z0-9-_u4e00-u9fa5]{1,30}$/;
if (!pattern.exec (handle.value)) return "must be Chinese letter or number!";
return true;
}
Determine if the menu name: can be alphanumeric Chinese-_
function Ismenuname (handle) {
var pattern =/^[a-za-z0-9-_u4e00-u9fa5]{2,200}$/;
if (!pattern.exec (Handle.value)) {return "must be a Chinese letter or number <br> and the length should be greater than or equal to 2 bits or less equal to 40 bits!";
Handle.value= '
}return true;
}
Here's how to use pattern to remove whitespace and space codes
var triminfo =
{basic://
Simple white-space character filtering in VB
, Classic:/s/
Traditional JS White-space character filtering
, Ecmascript5:/[sxa0u1680u180eu2000-u200au2028u2029u202fu205fu3000]/
Supplementary definition for/s in ECMAScript 5
, ex:/[sxa0u2028u2029]/
The impression is related to the identifier or string in JS, forget where it came from XD
, Control:/[x00-x1fx7f-x9f]/
A simple filter that adds control characters
, dotnet:/[sxa0u2000-u200bu3000ufeff]/
The default implementation of the. NET Platform
, Unicode:/[sx85xa0u1680u180eu2000-u200au2028u2029u202fu205fu3000]/
Filtering whitespace characters defined in the Unicode standard
, Complex:/[x00-x20x7f-xa0u1680u180eu2000-u200bu2028u2029u202fu205fu3000ufeff]/
Composite filtration, is the combination of the above several
};