php - Form submission blocked by bootstrapValidator -
i have problem when try submit form uses bootstrapvalidator() validating fields -> doesn't submit, php file not executed (i know because i've tried without booststrapvalidator , works). idea?
form looks this:
<form id="contactform" class="form-horizontal" role="form" action="contact_form.php" method="post"> <div class="form-group"> <label class="control-label col-sm-2" for="name">name</label> <div class="col-sm-10"> <input type="text" class="form-control" id="name" name="name" placeholder="name"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="email">email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="msg">mesage</label> <div class="col-sm-10"> <textarea class="form-control col-sm-10" id="msg" name="msg" placeholder=""></textarea> </div> </div> <div class="form-group"> <label id="captchaoperation" class="control-label col-sm-2" for="captcha"></label> <div class="col-sm-10"> <input type="text" class="form-control" id="captcha" name="captcha" placeholder="answer"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" class="btn btn-primary" id="submit" name="submit" value="send"></button> </div> </div> </form>
remove id="submit" name="submit"
, </button>
from
<input type="submit" class="btn btn-primary" id="submit" name="submit" value="send"></button>
add data-toggle="validator"
in <form>
<form id="contactform" class="form-horizontal" role="form" action="contact_form.php" method="post" data-toggle="validator">
so complete form be
<form id="contactform" class="form-horizontal" role="form" action="contact_form.php" method="post" data-toggle="validator"> <div class="form-group"> <label class="control-label col-sm-2" for="name">name</label> <div class="col-sm-10"> <input type="text" class="form-control" id="name" name="name" placeholder="name"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="email">email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="email" name="email" placeholder="example@domain.com"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="msg">mesage</label> <div class="col-sm-10"> <textarea class="form-control col-sm-10" id="msg" name="msg" placeholder=""></textarea> </div> </div> <div class="form-group"> <label id="captchaoperation" class="control-label col-sm-2" for="captcha"></label> <div class="col-sm-10"> <input type="text" class="form-control" id="captcha" name="captcha" placeholder="answer"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <input type="submit" class="btn btn-primary" value="send"> </button> </div> </div> </form>
and bootstrap validator code example
$(document).ready(function(){ $('#contactform').bootstrapvalidator({ icon: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, excluded: [':disabled'], fields: { name: { validators: { notempty: { message: 'the full name field required' } } }, email: { validators: { notempty: { message: 'the email field required' } } }, msg: { validators: { notempty: { message: 'the message field required' } } }, captcha: { validators: { notempty: { message: 'the captcha field required' } } } } }); });
and submit form after validation, actual reason form not submit after validation id="submit" name="submit"
inside submit
button type type="submit"
(fiddle name & id = submit) reason unknown why bootstrapvalidator not submit form, possible bug may got confused input type="submit" id="submit" name="submit"
either remove id="submit" name="submit"
(fiddle without name & id = submit) or change different type="submit"
id="sub" name="sub"
(fiddle name & id = sub)
Comments
Post a Comment