Possible Duplicate:
AJAX Form Submission in jQuery Mobile
I have a form and I use jQuery to check and validate the form, so that, if the form is empty, it won't submit the form and will just alert "Please fill in all the fields".
function doShowError( eForm, sField, iInd, sError ) {
var $Field = $( "[name='" + sField + "']", eForm ); // single (system) field
if( !$Field.length ) // couple field
$Field = $( "[name='" + sField + '[' + iInd + ']' + "']", eForm );
if( !$Field.length ) // couple multi-select
$Field = $( "[name='" + sField + '[' + iInd + '][]' + "']", eForm );
if( !$Field.length ) // couple range (two fields)
$Field = $( "[name='" + sField + '[' + iInd + '][0]' + "'],[name='" + sField + '[' + iInd + '][1]' + "']", eForm );
//alert( sField + ' ' + $Field.length );
$Field.parents('div:first').addClass( 'error' );
$Field
.parents('div:first')
.addClass( 'error' )
.children( 'img.warn' )
.attr('float_info', sError)
//.show()
;
}
Right now, the problem is that, whenever I click on the submit button, I get redirected to the page (which is supposed to be the user-panel ) with just a text saying:
undefined
How can I disable what the jQuery button do by default?
Edit:
My event fires and the message shows , but I'm still redirected to the URL defined in the form's attribute action
.