Use the js regular expression to verify the mobile phone number, email address, and zip code. If you want to verify your mobile phone number, you can refer to it for reference. (11 digits are entered at the beginning of "13" and "158,159)
The Code is as follows:
Var re;
Var ss = document. getElementById ('textbox3 '). value;
Re =/^ (13 [0-9] {9}) | (15 [89] [0-9] {8}) $/
If (re. test (ss ))
{
Document. getElementById ('label3'). innerText = ""; // assign a value to the label using innerText
}
Else
{
Document. getElementById ('label3'). innerText = "enter the correct mobile phone number! ";
Document. getElementById ('imagebutton1'). disabled = true; // disable disabled for Button
}
Verify the email address (including @ and .)
The Code is as follows:
Var re;
Var ss = document. getElementById (textboxid). value;
Re =/\ w @ \ w * \. \ w/
If (re. test (ss ))
Document. getElementById ('label4'). innerText = "";
Else
{
Document. getElementById ('label4'). innerText = "enter the correct email address! ";
Document. getElementById ('imagebutton1'). disabled = true;
}
Zip code verification (cannot start with 0, 6 digits in total)
The Code is as follows:
Var ss = document. getElementById ('textbox4 '). value;
Var re =/^ [1-9] [0-9] {5} $/
If (re. test (ss ))
Document. getElementById ('label5'). innerText = "";
Else
{
Document. getElementById ('label5'). innerText = "Incorrect zip code format! ";
}
Var r =/^ 13 [012345789] {9}/11 digits starting with 13, the last 9 digits cannot contain 6 digits