When multiple text boxes are validated with onblur (), the page goes into a dead loop

Source: Internet
Author: User

Welcome to Technical Exchange. qq:138986722

Recently in the old project to verify that the text box is a number, cannot be empty, can not repeat these things.

When I do a good job, I suddenly found that each text box with the management onblur () event to trigger the validation, the result entered the dead loop.

Closing the page has to be done with the process (or right-click off) ...

Okay, no more nonsense, talk about the solution first:

Multiple text boxes are treated with a onblur method, if else structure is used

function Prmecnoteonblur () {var Prmec = jQuery ("#groupNum"). Val ();
	var PRM = jQuery ("#prmBillNo"). Val ();
	var servicenum = jQuery (' #serviceNum '). Val (); if (Prmec==null | |
		prmec== "") {jQuery (' #prmecNote '). html (' <font color= ' red ' >prmec number cannot be empty </font> '); 
		JQuery (' #groupNum ') [0].focus ();  
	return false; else if (Prm==null | | 
		prm== "") {jQuery (' #prmecNote '). HTML ("");
		JQuery (' #prmNote '). html (' <font color= "Red" &GT;PRM billing number cannot be empty </font> ');        
		JQuery (' #prmBillNo ') [0].focus ();
	return false; }else if (Servicenum = = "" | | 
		Servicenum = = null) {jQuery (' #prmNote '). HTML (""); JQuery (' #serNote '). html (' <font color= ' red ' > Service number is not allowed to be empty, please enter the service number.
		</font> ');
		JQuery (' #serviceNum '). Select ();
	return false; 
		}else if (servicenum!= "") {jQuery (' #serNote '). HTML ("");  return Chekservicenum (); 
		Verify non-repeatable methods}else{//Empty error hints JQuery (' #prmecNote '). HTML (""); 
		JQuery (' #prmNote '). HTML ("");   
	JQuery (' #serNote '). HTML ("");
return true; }
This will be called at the time of submission:

if (!prmecnoteonblur ()) {return
		;  
}

Being go ... Eat rice bird ...






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.