Search code examples
jqueryvalidationjquery-validation-engine

using button instead of submit in jquery validation engine


I am using input type = button instead of input type = submit to submit a form values. Now I want to validate all text box, select box and check box while clicking that button, how do I do that? help me


Solution

  • Follow the below steps,

    1. Get the value of the text box like,

      var controlValue = $("#controlid").val();
      
    2. The do the validation using the condition as required, say for example as,

      if(txtBox1 != "")
      {
          alert("error"); 
      }
      
    3. If all conditions passed then submit the form.

      $("form[0]").submit();