0

I used the jquery.bassistance validation plugin. For validation on my fields. Now i want validation on my arrival text box. I want that he validate on this box. The only characters that you used in this checkbox are numbers and the :.

How can i make that. I used now this code:

$(".validate").validate({ rules: { email: { required: true, email: true }, number: { required:true, minlength:3, phoneAus:true }, math: { equal: 11 }, agree: "required" }, messages: { email: "Vul een geldig email adres in", agree: "Je moet nog akkoord gaan met voorwaarden" }, errorLabelContainer: $("form .error-messages") }); 

But the number validation. Validate on numbers. How can i fix that the number validation. Accept the : sign.

Thanks

1
  • could you show us the html form!? Commented Jul 10, 2012 at 9:51

1 Answer 1

1

Try adding a custom regex rule, here is a starting point, you will need to update the regex to your specific requirements:

$(function () { $.validator.addMethod("customRegex", function(value, element) { return this.optional(element) || /^[0-9\:]+$/i.test(value); }, "must contain only numbers, or a colon."); $(".validate").validate({ rules: { "fieldId": { required: true, customRegex: true, } }, messages: { "fieldId": { required: "You must enter a xyz", customRegex: "format not valid" } } }); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.