Since there is no dedicated forum to the Validator, I'll post it here.
I have a form with a Validator applied to a text input. Works well except for submitting the form. According to the docos "Note that if a HTML form element is set as validation container, the form submits will be automatically prevented if validation fails."
This is not the case as my form submits anyway. I'm checking for false on the button click at the moment, but it doesn't work for anything. I would like submisson of forms to be disabled as per the documentation.
Any ideas?
I have a form with a Validator applied to a text input. Works well except for submitting the form. According to the docos "Note that if a HTML form element is set as validation container, the form submits will be automatically prevented if validation fails."
This is not the case as my form submits anyway. I'm checking for false on the button click at the moment, but it doesn't work for anything. I would like submisson of forms to be disabled as per the documentation.
Any ideas?
@<
div
id
=
"searchform"
>
<
form
method
=
"get"
action
=
"@Href("
~/Collection/Search")"
class
=
"search"
>
<
ul
>
<
li
>
<
input
type
=
"text"
name
=
"q"
value
=
"@q"
class
=
"k-textbox"
required />
</
li
>
<
li
>
<
button
class
=
"k-button"
id
=
"search"
>Search</
button
>
</
li
>
</
ul
>
</
form
>
<
div
class
=
"status"
>
</
div
>
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
var validator = $("#searchform").kendoValidator({
rules: {
custom: function (input) {
return input.val().length > 3;
}
},
messages: {
custom: "You need 3 or more characters",
required: "Oops, you forgot me!",
email: function (input) {
return getMessage(input);
}
}
}).data("kendoValidator");
$("#search").click(function () {
if (validator.validate() == false) {
}
});
});
</
script
>
</
div
>