I'm trying to use the jQuery validation plugin to validate some text fields on the fly. One of the rules is the field cannot contain 'http'. How would I modify the validate() method to achieve this?
@using (Html.BeginForm("UserDetails", "Account", FormMethod.Post, new {id = "registerform" }))
{
<input id="Facebook" minlength="2" name="Facebook" placeholder="eg: Joe.Bloggs123" type="text" value>
...
}
<script>
$('#registerform').validate({
// ...?
})
</script>
Edit: I tried adding a the validator.addmethod but it still doesn't work. SO here is what I have in the script:
$('#registerform').validate();
jQuery.validator.addMethod("Facebook", function(value, element) {
return this.optional(element) || (value.indexOf('http') >= 0);
}, "*Please just use your userid, not the full url");
Also I would need to validate a lot of these, is it not possible to add a custom class and select from that?