ruby on rails - submit function of jquery submit form and not validate the livevalidation -
i have used livevalidation.js validating form field. can't validate radio button live validation have written following code on form submit jquery event.
the problem that, when select these radio buttons , not other fields of form, submit form , model validation applied, should applied live-validation.
what problem in code or submit function?
$('#new_league_info').submit(function(){ if($('#league_info_state').val() != '') { if($('.re_conditioner_radio').is(':checked')){ $('#reconditioner_msg').css("hidden"); var spans = $('.reconditioner_err'); spans.text(''); } else{ $('#reconditioner_msg').replacewith('<span class=" reconditioner_err lv_invalid">please select reconditioner</span>'); return false; } } if ($(".view_offer_checkbox").is(':checked')){ $('#manufacturer_msg').css("hidden"); var spans = $('.manufacturer_err'); spans.text(''); } else{ $('#manufacturer_msg').replacewith('<span class=" manufacturer_err lv_invalid">please select manufacturer</span>'); return false; } });
use
e.preventdefault();
to prevent default behaviour when submit-button clicked , own validation:
$('#new_league_info').submit(function(e){ e.preventdefault(); ...
Comments
Post a Comment