SoFunction
Updated on 2025-03-03

Use js regular expression to verify mobile phone number, email address, and postal code

Verification of mobile phone number (starting at 13 and starting at 158, starting at 159, total 11 digits)

Copy the codeThe code is as follows:

var re;
var ss=('textbox3').value;
re= /^(13[0-9]{9})|(15[89][0-9]{8})$/
if((ss))
 {
('label3').innerText="";   //Add innerText to label
 }
else
{
('label3').innerText="Please enter the correct mobile phone number!";
('imagebutton 1').disabled=true; //Disable Button to use disabled
}

Verification of email address (including @ and .)
Copy the codeThe code is as follows:

  var re;
  var ss=(textboxid).value;
  re= /\w@\w*\.\w/
 if((ss))
   ('label4').innerText="";
 else
 {
('label4').innerText="Please enter the correct email address!";
   ('imagebutton1').disabled=true;
 }

Verification of postal code (cannot start with 0, total 6 digits)
Copy the codeThe code is as follows:

var ss=('TextBox4').value;
var re= /^[1-9][0-9]{5}$/
if((ss))
  ('label5').innerText="";
else
{
('label5').innerText="The postal code format is incorrect!";

}

var r= /^13[012345789]{9}/ 11 digits starting with 13, the last 9 digits cannot appear 6