Frage

I'm using validationEngine for jQuery and for the most part find it works perfectly, however, for the first time I've had to add my own custom validation check and it isn't matching at all.

I'd like to validate that it's a UK phone number, without any strange characters or spaces, and it has to be 11 characters long, I assume using this regexp: /^[0-9]{11}$/

Here's my full validation rule:

"ukPhoneNumber": { "regex": /^[0-9]{11}$/,
                    "alertText": "Must be a full UK phone number",
                    "alertText2": "Example: 01452123456 "
                }

And then in my input, I'm using class="validate[ukPhoneNumber]" - however, no matter what I enter into the input, it will not display the alert text or stop me submitting the form.

Any idea what I'm doing wrong please? My regexp could be incorrect, but I've also tried copying from another (working) class to test and it still doesn't work.

War es hilfreich?

Lösung

Sigh, sorry all - just figured this one out, you need to specify that it's a custom validation in the class:

class="validate[custom[ukPhoneNumber]]"

(I would delete this post, but figure it could be useful for someone else)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top