I'm using jquery Form Wizard, and would like to write custom validation rules.
My current issue is that I would like to validate a field as a URL, but if the user forgot to add the "http://" prefix, I would like to not reject this, and instead add the prefix on the server side.
I'm currently using the url
class for this validation, which doesn't support this option. To resolve, I would like to use a custom regex instead of the url
validator (basically, just check that the URL field has a period and is at least five characters long).
I haven't been able to make jquery-ui-form-wizard use a regex or call a callback function to validate. Note - I want to validate on each step, not just on submit.
I add the following to the form wizard options, and my callback is called - but even if it returns false, clicking next still proceeds to the next page:
remoteAjax: {
"page1" : {
url: "./validateWizard1",
dataType: "json",
beforeSend: function() {
// This code is called before "page1" is turned.
return false;
},
success: handleValidateSubmit
}
}
I would want to either set a custom error message (to be displayed in the standard way to the validations plugin), or reuse the URL message.
What's the best way to achieve this?