javascript - How to submit a form using jQuery? -
i want submit form using jquery, have 4 fields needed checked, when submit, displays first alert submit
doesn't check if fields valid or not. what's error in code? appreciated.
$(document).ready(function(){ $('input[name=subdomain]').keyup(subdomain_check); $('input[name=password]').keyup(password_strenght); $('input[name=c_password]').keyup(password_check); $('input[name=email]').keyup(email_check); $('#install').on('submit', function(){ alert("submit"); if ($('input[name=subdomain]').valid() == true && $('input[name=password]').valid() == true && $('input[name=c_password]').valid() == true && $('input[name=email]').valid() == true){ alert("true"); return true; } else { alert("false"); return false; } }); });
here's html form :
<form class="form-horizontal" method="post" id="install" action="etape2.html" role="form"> <input type="hidden" id="install-element-0" value="install" name="form"> <input type="hidden" id="install-element-1" value="insert" name="action"> <div class="col-md-6"> <input type="text" id="install-element-2" required="" name="title" class="form-control input-md col-md-6"> </div> <div class="col-md-6"> <input type="text" id="install-element-3" required="" name="first_name" class="form-control input-md col-md-6"> </div> <div class="col-md-6"> <input type="text" id="install-element-4" required="" name="last_name" class="form-control input-md col-md-6"> </div> <div class="col-md-6"> <input type="text" id="install-element-5" required="" name="email" class="form-control input-md col-md-6"> </div> <div class="col-md-6"> <input type="password" id="install-element-6" required="" class="form-control input-md col-md-6" name="password"> </div> <div class="col-md-6"> <input type="password" id="install-element-7" required="" class="form-control input-md col-md-6" name="c_password"> </div> <div class="col-md-6"><input type="text" required="" placeholder="" id="subdomain" name="subdomain" class="form-control input-md col-md-6"> <div class="form-actions col-md-9 col-md-offset-3 text-right"> <input type="submit" id="install-element-9" class="btn btn-primary" name=""value="valider"> </div> </div> </form>
is there way check functions return
, not validate
?
add:
$('#install').on('submit', function(e){ e.preventdefault(); [..] }
to code
Comments
Post a Comment