javascript - jquery-form-validator: elem undefined -
i elem not defined except when try validate form:
typeerror: elem undefined .attr() jquery.js:7501 access()
jquery.js:4010 .attr() jquery.js:7488 $.formutils<.validateinput()
jquery.form-validator.js:1397 $.fn.validateinputonblur()
jquery.form-validator.js:663 $.fn.validate/<()
jquery.form-validator.js:605 .each() jquery.js:362
jquery.prototype.each() jquery.js:157 $.fn.validate()
jquery.form-validator.js:594 showformasdialog() form.js:150
_onclickopenform() form.js:42 jquery.event.dispatch() jquery.js:5205 jquery.event.add/elemdata.handle() jquery.js:5014 jquery.js:7501:4
$(document).ready(function() { var server = "http://testomat.trinamo.ch"; var approot = "barracuda_formular"; //datepicker init initdatepicker('.datepicker'); $(".showformlink").on('click', _onclickopenform); // // $('.multiform').submit(_submithandlerchecksubmit); //? <------------- !!!! }); //callbacks_________________________________________________________________________________________________________________________________ //executed when user clicks link open form function _onclickopenform() { var forminstance = $(this).attr('data-form'); var formfile = $(this).attr('data-formfile'); if (ismobile()) { //redirect redirecttoform(formfile); } else { //show dialog showformasdialog(forminstance); } //end callback------------------------------------------------------ function submitformviahttpcommand(form) { console.log(form); var appbase = "barracuda_formular"; $.post( "app_server/logic/formmailer.php", form.serializearray() //this form ); } function initdatepicker(datepickerselector) { $.datepicker.setdefaults($.datepicker.regional[""]); $(datepickerselector).datepicker($.datepicker.regional.de); } function createdialog(title, text, options) { return $("<div class='dialog' title='" + title + "'><p>" + text + "</p></div>") .dialog(options); } function ismobile() { if (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent)) { return true; } else { return false; } } function redirecttoform(formfile) { window.location.href = "?page=" + formfile; } function showformasdialog(forminstance) { var browsersize = { width: window.innerwidth || document.body.clientwidth, height: window.innerheight || document.body.clientheight }; $("#" + forminstance).dialog({ width: "66%", modal: true, }); $("#myformmultiform").validate({ //this causes error submithandler: function(form) { alert("test"); return false; } }); }
this form
<form class="multiform" id="myformmultiform" method="post" action="app_server/logic/formmailer.php"> <div class="row"> <div class="col-md-6"> <span class="label label-default">anrede</span> </div> <div class="col-md-6"> <select class="form-control" id="inputanrede" name="anrede" data-validation="required"> <option>frau</option> <option>herr</option> </select> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">name</span> </div> <div class="col-md-6"> <input type="text" name="name" data-validation="required" class="form-control" id="inputname" placeholder="name"> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">vorname</span> </div> <div class="col-md-6 "> <input type="text" class="form-control" id="inputvorname" data-validation="required" placeholder="vorname" name="vorname"> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">email</span> </div> <div class="col-md-6 "> <input type="email" data-validation="email" class="form-control" id="inputemail" placeholder="email" name="email"> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">telefon</span> </div> <div class="col-md-6 "> <input type="tel" data-validation="custom" data-validation-regexp="^\+?[0-9]+$" class="form-control" id="inputtel" placeholder="telefon" name="telefon" data-validation-error-msg="bitte geben sie eine telefonnummer ein"> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">datum</span> <!-- datum darf natÜrlich nicht in der vergangenheit liegen! --> </div> <div class="col-md-6" > <input class="datepicker" data-validation="date" data-validation-format="dd.mm.yyyy" data-provide="datepicker" name="datum" data-validation-error-msg="bitte geben sie ein gültiges datum an."> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">anzahl personen</span> </div> <div class="col-md-6"> <input type="number" class="form-control" data-validation="number" data-validation-allowing="range[1;99]" id="inputcountperson" name="personen" placeholder="anzahl personen" data-validation-error-msg="bitte überprüfen sie die anzahl personen"> </div> </div> <div class="row"> <div class="col-md-6"> <span class="label label-default">bemerkung</span> </div> <div class="col-md-6 "> <textarea class="form-control" name="bemerkung" id="inputbemerkung" rows="10"></textarea> </div> </div> <div class="row"> <div class="col-md-12"> <input id="submitbutton" type="submit" value="submit" class="submit"> </div> </div> </form>
when call validate without specific form selector, validation works , no error. can't set submithandler seems
Comments
Post a Comment