jQuery validator plugin not catching the submit action -
basically, when click submit, sends me next page instead of preventing post. it's not validating anymore, needs happen too. how go fixing this?
javascript:
<script language="javascript" type="text/css"> jquery.validator.addmethod( "nostateselected", function(value, element) { if (element.value == "") { return false; } else return true; }, "" ); jquery.validator.messages.required = ""; $(document).ready(function(){ $("#newmemberform").validate({ invalidhandler: function(e, validator) { var errors = validator.numberofinvalids(); if (errors) { var message = errors == 1 ? 'you missed 1 field. has been highlighted below.' : 'you missed ' + errors + ' fields. have been highlighted below.'; $("div.error span").html(message); $("div.error").show(); } else { $("div.error").hide(); } }, submithandler: function() { $(#newmemberform).submit(); }, errorlabelcontainer: "#messagebox", wrapper: "li", onkeyup: false, submithandler: function() { $("div.error").hide(); $("label.error").remove(); }, rules: { sponsor: "required", username: "required", password: "required", first_name: "required", last_name: "required", phone_number: "required", tax_id: "required", address_1: "required", city: "required", postal_code: "required", profile_statelist: { nostateselected: true }, email: { required: true, email: true }, terms_conditions: "required" }, messages: { email: { email: "your email address must in format of name@domain.com ." }, terms_conditions: "you must agree conditions." } }); }); </script>
html:
<form name="newmember" id="newmemberform" action="~secure_url~/cgi-bin/xflow/newuser.cgi" method="post"> .... [conditional input text box required if exists] ... </form>
you have bad selector on sumbit action (you missing quotes):
submithandler: function() { $(#newmemberform).submit(); },
should be:
submithandler: function() { $("#newmemberform").submit(); // quotes here },
Comments
Post a Comment