Simple instance of form validation when the text box loses focus

Source: Internet
Author: User

A simple instance of form validation occurs when the text box loses focus:
A lot of forms validation has such a function, that is, when the mouse focus away from the text box, the legitimacy of validation immediately, the following is a simple example of how to implement this function, code examples are as follows:

<Scripttype= "Text/javascript"> functiononblurs () {if(Myform.name.value=="") {alert ("the name must not be empty! "); }  Else if(Myform.address.value=="") {alert ("the address must not be empty! "); } } </Script> </P><P></Head><Body><formname= "MyForm"> <Table>  <TR>     <TD>Name:</TD>     <TD><inputtype= "text"name= "Name"/></TD>   </TR>  <TR>     <TD>Address:</TD>     <TD><inputtype= "text"name= "Address"/></TD>   </TR> </Table></form> </Body></HTML>

The above code copy paste can be tested, the code is very simple, here is not analyzed.
Related reading:
The onblur event can be found in the Onblur event section of JavaScript .

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=8835

For more information, refer to: http://www.softwhy.com/javascript/

Simple instance of form validation when the text box loses focus

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.