Form verification is essential for almost every website that needs to be registered or logged in. Some verifications are very complex and can be said to be various requirements for you. However, this chapter only introduces the simplest verification method in the form, which is to determine whether it is empty. Some websites with relatively low requirements have already met the needs.
The code is as follows:
<html> <head> <meta charset="gb2312"> <title>jsSimple form verification</title> <script type="text/javascript"> =function() { var bt=("bt"); =function() { if(=="") { alert("The username cannot be empty!"); (); return false; } else if(=="") { alert("The password cannot be empty!"); (); return false; } } } </script> </head> <body> <form action="" method="get" name="myform"> <ul> <li>Name:<input type="text" name="name" /></li> <li>password:<input type="text" name="pw" /></li> <li><input type="submit" /></li> </ul> </form> </body> </html>
The above is the detailed content of this article, I hope it will be helpful to everyone's learning.