Details about JavaScript form verification (E-mail verification) and javascript form
This article shares JavaScript form verification. The typical form data verified by JavaScript includes:
Have you entered required items in the form?
Is the email address entered by the user valid?
Have you entered a valid date?
Does the user input text in the data field (numeric field?
Required (or required) project
The following function is used to check whether the user has entered a required (or required) project in the form. If required or required, the warning box is displayed, and the return value of the function is false. Otherwise, the return value of the function is true (meaning there is no data problem ):
function validate_required(field,alerttxt){with (field){if (value==null||value=="") {alert(alerttxt);return false}else {return true}}}
The following code is used together with the HTML form:
Email Verification
The following function checks whether the input data conforms to the basic syntax of the email address.
That is to say, the input data must contain the @ symbol and the dot (.). At the same time, @ cannot be the first character of the email address, and @ must have at least one dot:
function validate_email(field,alerttxt){with (field){apos=value.indexOf("@")dotpos=value.lastIndexOf(".")if (apos<1||dotpos-apos<2) {alert(alerttxt);return false}else {return true}}}
The complete code of the HTML form is as follows:
The above is all of the content in this article. I hope it will help you learn javascript form verification.
Articles you may be interested in:
- Collection of JavaScript form verification control code Daquan
- Regular Expressions for JavaScript form verification [recommended]
- Sample Code for JavaScript Form Verification Using Regular Expressions
- Javascript Regular Expression Form Verification Code
- Getting started with jquery validate. js Form Verification
- Javascript Form Verification
- Simple js form verification functions
- Javascript Form Verification example (javascript verification email)
- AngularJS implements Form Verification