Issue binding validation on submit
2 forms, one submit button - that works, I can't get the validation to bind to the submit function...any ideas?
$("#sbtBtn").click(function() {
if($("input[name=license_code]").val()) { //check if #retUser has a value
$
("#formOne").submit();
} else if ($("input[name=referred_by_text]").val() && $("input[name=broker_text]").val() && $("input[name=email1]").val()) {
$
("#formTwo").submit();
}
else {
alert
("Please fill out either the returning user or new user form");
}
});
$
("#formOne").submit(function() {
//if (valid) $(this).submit();
var validator = $("#formOne").validate({
errorElement
: "em",
//errorContainer: $("#summary"),
errorPlacement
: function(error, element) {
error
.appendTo( element.parent("li"));
},
submitHandler
: function(form) {
var dataString = $(form).serialize();
$
.ajax({
type
: $(form).attr('method'),
url
: form.action,
data
: dataString,
success
: function(data, status) {
$
("#currentUser, #newUser, #submitContain").hide();
},
error
: function (data, status) {
$
("#newUser, #submitContain").hide();
$
("#currentUser").html("error");
}
});
return false;
},
rules
: {
license_code
: {
minlength
: 2
}
},
messages
: {
license_code
: {
minlength
: "Your Code Must be at Least 2 Characters"
}
}
});
});
$
("#formTwo").submit(function() {
alert
("formTwo");
return false;
});
Kane Leins