You have a bunch of issues...
1) You are not including the jQuery Validate plugin at all in your jsFiddle and if your comments are correct, you cannot include jQuery after the plugins. jQuery gets included first, then any jQuery plugins.
2) Your ID selector is wrong. In your <form>
tag, you have id="form1"
but in your jQuery selector, you have #Form1
. This is case-sensitive.
3) The jQuery validate plugin mandates that the inputs have unique name
attributes. You don't have any name
attributes at all. This is going to be a game-stopper. The plugin will not work without a name
attribute on each input
element to be validated.
4) The messages
option is spelled "messages"
. You've misspelled it as "message"
.
5) You don't need an inline click handler on your button. Just make it a type="submit"
and allow the plugin to handle it automatically. This means that you do not need to wrap .validate()
inside another function. Just put it inside a DOM ready event handler so the form is setup and ready as soon as the page loads.
This one gets you closer: http://jsfiddle.net/dxEEe/2/
EDIT based on commnets:
To submit using the click of a type="button"
would only require a click
handler to capture the button.
$("#btnSave").click(function() {
$("#form1").submit();
});
OR
$("#btnSave").on('click', function() {
$("#form1").submit();
});
Although, I don't understand the point of this, as ultimately, the only thing inside your click
handler is a submit
. In other words, simply using a type="submit"
button would have the exact same functionality without needing any click
handler function.
(In your jsFiddle, "function"
was misspelled as "functioin"
. I think you just need to slow down as many of your issues have to do with spelling.)