this is a simple question. I have a form that is being validated using jquery’s .validate function.
The problem is that validating only seems to work when I submit the form using: <input type='submit' />
However, I would like to use my own custom button using instead: <button type="submit">click to submit</button> …. or use something like… <a onclick="submitFunction ()">click to submit</a>
These last two options however, do not trigger jquery’s validate function. Is there a way around this? Thanks for the help in advance!
The jQuery Validation plugin is tied to the
submitevent in jQuery. If you want to trigger this from anywhere else (i.e. any other event handler), you will have to call.submit()manually, which will trigger the validation to occur.Note that after calling
.validate()to set up validation on your form you can store theValidatorinstance it returns and call theformmethod on it if you want to perform the validation separately from the submission of the form.