validation - jQuery validate while using .submit() or .load() -
i have form loading results div, , jquery validate doesn't recognize need field validated because there no actual "submit" going on, right? how can bypass , still validate field?
$('#idsearchform').validate({ rules: { term: { required: true, minlength: 2 }, } });
..no worky :(
$(document).ready(function() { $('#idsearchform').validate({ rules: { term: { required: true, minlength: 4 }, } }); $('.activeview').click(function() { $('.activemask').slidetoggle(250); $('.list-style-arrow').toggleclass('nudge'); }); function showloader(){ $('.search-background').fadein(200); } //hide loading bar function hideloader(){ $('.sub_cont').fadein(1500); $('.search-background').fadeout(200); }; $('.searchinput').keydown(function(e) { if(e.keycode == 13) { $('#idsearchform').valid(); showloader(); $('.sub_cont').fadein(1500); $('.content .sub_cont').load('superfetch.php?val=' + $('.searchinput').val(), hideloader()); e.preventdefault(); } }); $('.searchbtn').click(function(){ $('#idsearchform').valid(); //show loading bar showloader(); $('.sub_cont .loader').fadein(1500); $('.content .sub_cont').load('superfetch.php?val=' + $('.searchinput').val(), hideloader()); }); });
you can call when want validate it
$('#idsearchform').valid();
that return true or false
edit new information
if(e.keycode == 13) { if($('#idsearchform').valid()){ showloader(); $('.sub_cont').fadein(1500); $('.content .sub_cont').load('superfetch.php?val=' + $('.searchinput').val(), hideloader()); } e.preventdefault(); }
Comments
Post a Comment