Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140071

jQuery validation is not working.. can youtell me this code is right or wrong?

$
0
0

Im using jQuery validation, the validation is working properly but after fill the field click submit button always shows its not a valid form alert msg.. but all the field is filled.. i dont know why is restricted to submit..

anyone tell me why?

Can you tell me anything mistake in my code????

fiddle code is here..

Fiddle code is here..

Here is my code..

$(document).ready(function() {

  $('#contactForm').validate({
    rules: {
      accountName: {
        required: true
      },
      narr: {
        required: true
      },
      debit: {
        required: true
      },
      cashactcode: {
        required: true
      }
    },
    submitHandler: function(form) {
      alert('valid form');
      return false;
    }
  });
  $('#cashSub').on('click', function() {
    $('#contactForm').valid();
    alert('its not a valid form');
    return false;
  });

});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"><script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script><script src="https://code.jquery.com/jquery-3.4.1.min.js"></script><!-- jquery validation cdn --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.2/css/bootstrapValidator.min.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.5.2/js/bootstrapValidator.min.js"></script><script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.19.0/jquery.validate.js"></script><form id="contactForm"><div class="table-wrapper"><div class="table-scroll"><table class="table table-bordered table-hover order-list" id="tab_logic"><tbody><tr id="fst_row" class="form-group"><td><select class="form-control sel_sel required" id="payacc" name="actname" for="actname" value=""><option value="">Select TDS A/c name</option><option value="1">TDS A/c 1</option><option value="2">TDS A/c 2</option><option value="3">TDS A/c 3</option></select></td><td class="form-group"><input type="text" class="form-control price required" id="pay_narrat" name="narr" for="narr" data-toggle="modal" maxlength="200" data-target="#narratModal" placeholder="Enter your text here" /></td></tr></tbody></table></div></div><div class="form-group col-4 vocSub" style="margin-bottom: 0px !important;"><div class="col-md-12 cashform_submit" id=""><input type="submit" class="btn add-btn submit-btn load cashmainBtn" id="cashSub" /></div></div></form>

Viewing all articles
Browse latest Browse all 140071

Trending Articles