Tuesday 15 January 2013

jquery - JavaScript return false is not stopping other functions from executing -


I have some JS functions that resemble the button while clicking on the "Save" button on a page: < / P>

  & lt; Img src = "images / btn / save.gif" name = "btn submit" onClick = "noSpaceTest (); minMaxValues ​​(); compare2dates (benefit_start_date, Benefit_end_date, 'javascript: saveNewBenefit ()')" width = " 60 "height =" 22 "range =" 0 "square =" btnimg "& gt;   

I'm interested in the function minMaxValues ​​(). If this test fails, then the form should not be submitted (in this case it means that no other work should be run.) I had made a wrong return; In the MinMaxValues ​​() function, and it runs (Bad Value Warning), but after dismissing the warning, other actions are called instead of Pausing .

Function:

  // Maximum profit value More minimum profit Price Function Max Maxwell () (var maxAmt = ($ ('# maxAmount')) function of validation Val ()); Var minAmt = ($ ('# minAmount'). Val ()); If ((Minamat! = '') & Amp; amp; (maxAmt! = '')) {Try {maxAmt = parseInt (maxAmt); MinAmt = parseInt (Minimat); If (MaxAmt   

Is there any way to allow any other not to execute any other work if it returns a wrong?

  "submit btn" onClick = "noSpaceTest (); minMaxValues ​​()? : Return; compare2dates (benefit_start_date, benefit_end_date, 'javascript: saveNewBenefit ()') "width =" 60 "height =" 22 "range =" 0 "square =" btnimg ">   

or

  "submit btn" onClick = "noSpaceTest (); if (! MinMaxValues ​​()) {return}; compare2dates (benefit_start_date) , Benefit_end_date, 'Javascript: saveNewBenefit ()') "width =" 60 "height =" 22 "range =" 0 "square =" btnimg "& gt; Preventing from submitting   

as well as preventing other tasks from being executed

Edit: You click on Clean Clean it Handler function, this is just a quick fix

No comments:

Post a Comment