Refer to the JS form verification for easy viewing

Source: Internet
Author: User
Tags domain name registration to domain

1:js string length limit, judge character length, JS limit input, limit cannot be entered, textarea length limit

2.:js Judge Chinese characters, judge whether Chinese characters, can only input Chinese characters

3:js judge whether to enter English, only input English

4:js can only enter numbers, judge numbers, verify numbers, detect numbers, determine whether they are numeric, enter only numbers

5: Only English characters and numbers can be entered

6:JS Email verification, JS judgment email, mailbox/email format Verification

7:js character filtering, masking keywords

8:js password verification, password determination

2.1:js is not empty, empty, or not an object, judgment is empty, judgment is not empty

2.2: Compare values of two table items

2.3: The form can only be numbers and "_",

2.4: Table Item input value/length limit

2.5: Chinese/English/digital/e-mail address legality judgment

2.6: Limit the characters that the form item cannot enter

2.7 Control of the form's self-character

Universal Check function for 2.8:form text fields

1. Length Limit

function Test () {    if(document.a.b.value.length>)    {        alert ( " no more than 50 characters! ");        Document.a.b.focus ();         return false ;    }}            

2. Can only be Chinese characters

3. "Can only be in English

function Onlyeng () {    if(!) ( event. keycode>=&&event. keycode<=))      Event. returnvalue=false;}

4. Can only be a number

function Onlynum () {    if(!) ( (event. keycode>=&&event. keycode<=)| | (event. keycode>=&&event. keycode<=)))     // Consider the numeric keys    on the keypad event. returnvalue=false;}

5. Only English characters and numbers

6. Verify the fuel tank format

function Isemail (stremail) {    if (Stremail.search (/^\w+ (-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ (\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/)! =-1)    returntrue;     Else     alert ("Oh");}

7. Block Keywords (shield * * * and * * * * here)

function Test () {if(A.b.value.indexof ("* * *"0) | | (A.b.value.indexof ("* * *0)") {alert (":)  " ); A.b.focus (); return false ;}}

8. Two times the same password is entered

function Check () {with (document.all) {if(input1.value!=input2.value) {alert (" false " """";} else document.forms[0].submit ();}}

Enough,:).

Shield Right button is cool

Oncontextmenu= "return False" false "false"

Add it to the body.

Two

2.1 The form item cannot be empty

2.2 Compare two table items for the same value

2.3 Form items can only be numeric and "_" for phone/bank account verification, can be extended to domain name registration, etc.

2.4 Table Item input value/length limit

2.5 Chinese/English/digital/e-mail address legality judgment

2.6 Characters that limit the entry of a form item

1. Check to see if a string is all made up of numbers

---------------------------------------

2. How to determine if it is a character

---------------------------------------

if (/[^\x00-\xff]/g.test (s)) alert ("contains Chinese characters");

else alert ("All characters");

3. How to determine if a Chinese character is included

---------------------------------------

if (Escape (str). IndexOf ("%u")!=-1) alert ("contains kanji");

else alert ("All characters");

4. Mailbox Format Verification

---------------------------------------

//function Name: Chkemail//function: Check if it is an email Address//parameter Description: The string to check//return value: 0: Not 1: Yesfunction Chkemail (a) {
varI=a.length; vartemp = A.indexof ('@'); varTEMPD = A.indexof ('.'); if(Temp >1) { if((i-temp) >3){ if((I-TEMPD) >0){ return 1; } } } return 0; }

5. Digital format Verification

---------------------------------------

//function Name: Fucchecknum//Function Description: Check whether it is a digital//parameter Description: The number to check//return Value: 1 is a number, 0 is not a numberfunction Fucchecknum (NUM) {vari,j,strtemp; strtemp="0123456789"; if(num.length==0)     return 0      for(i=0; i{J=Strtemp.indexof (Num.charat (i)); if(j==-1)     {     //indicates that a character is not a numberreturn 0; }     }     //description is a numberreturn 1; }     

6. Phone Number format verification

---------------------------------------

//function Name: Fucchecktel//Feature Description: Check if it's a phone number//parameter Description: The string to check//return Value: 1 is legal, 0 is illegalfunction Fucchecktel (TEL) {vari,j,strtemp; strtemp="0123456789-() #";  for(i=0; i{J=Strtemp.indexof (Tel.charat (i)); if(j==-1)     {     //indicates that there are characters that are not validreturn 0; }     }    //Description Legalreturn 1; }   

7. Determine whether the input is a Chinese function

---------------------------------------

function Ischinese (s) {   var ret=true;     for (var i=0; iret=ret && (s.charcodeat (i) >=10000);    return ret;   }    

8. A comprehensive function for judging the legality of user input

---------------------------------------

Refer to the JS form verification for easy viewing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.