Answer the question
In order to leave comments, you need to log in
How to solve ReferenceError: event is not defined in Firefox when using jquery.validate?
Forms are created dynamically. Handlers are assigned to them by the desFormAction($from) function. jquery.validate is used to validate input.
In chrome everything works without problems. Firefox throws an error ReferenceError: event is not defined.
function desFormAction($myfrom){
$myform.validate({
rules: validationRm['rules'],
messages: validationRm['messages'],
submitHandler: function() {
event.preventDefault();
//...
$.ajax({
//...
})
}
});
}
function desFormAction($myfrom){
$myfrom.children('input[type=submit]').click(function(event){
event.preventDefault();
$myfrom.validate({
rules: validationRm['rules'],
messages: validationRm['messages'],
submitHandler: function() {
//...
$.ajax({
//...
})
}
});
})
}
Answer the question
In order to leave comments, you need to log in
The problem was solved unexpectedly for me. When using jquery.validate, you don't need to explicitly specify event.preventDefault(). The plugin has already done this for you.
function desFormAction($myfrom){
$myfrom.submit(function(event){
event.preventDefault();
$myfrom.validate({
rules: validationRm['rules'],
messages: validationRm['messages'],
submitHandler: function() {
//...
$.ajax({
//...
})
}
});
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question