This article mainly introduces some common javascript form verification. at the end of this article, we also come with a practical case to illustrate how to verify numbers. interested friends can refer to the example to explain: verify whether the entered number is a number and whether the number is a number. if the number is incorrect, send a friendly reminder.
:
My first JavaScriptEnter a number. If the input value is not a number, a prompt box is displayed in the browser.
Script function myFunction () {var x = document. getElementById ("demo "). value; if (x = "") {alert ("input cannot be blank"); return;} if (isNaN (x )) {alert ("enter a number"); return;} if (x. length! = 6) {alert ("Please enter 6 digits"); return ;}} scriptClick here
The above example contains a lot of frequently used form verification code, which will be shared with you below:
1. verification form
2. verify the nickname
3. calculate the length of the nickname
4. verify that the nickname exists
5. verify the mobile phone number
6. verify the password
7. verify email
8. verify the verification code
9. determine whether or not to select
Registration Verification example: