Two functions + Validation problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hjaffer2001
    New Member
    • Aug 2010
    • 4

    Two functions + Validation problem

    Hi all,
    I have one form which has to do two functions on sumbit.
    The form looks lik this.
    <form method="post" id="searchlist " name="searchlis t" onsubmit="retur n (OnSubmitForm(r esult) && validate())">

    And the javascript is:
    Code:
    function OnSubmitForm(result)
    				{
    				  				
    				  if(result == 'Show_Results')
    				  {
    				  document.searchlist.action ="?action=show_results";
    				  }
    				  else if(result == 'Download_CSV')
    				  {
    				  	
    					document.searchlist.action ="?action=download_csv";
    				  }
    				  else if(result == 'Email_Results')
    				  {
    					document.searchlist.action ="?action=email_results";
    				  }
    				  		  
    				  document.searchlist.submit();
    				}
    				}
    Now, i want to add another one function validate(). This looks like
    function validate(){
    .....
    .....
    }

    As soon as i click the submit button it gets submitted and it does not pass through validate() function.
    Any Suggestions.

    Thanks
    Haan
    Last edited by Dormilich; Sep 27 '10, 06:21 AM. Reason: fixed [code] tags
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    if OnSubmitForm() returns false, validate() will be skipped ((false && ?) is always false)

    Comment

    Working...