Forums

How can i make my code to accept Numbers Only?

maxfard 05 Jan, 2011
hi there,
i have a piece of Java code which work well, but i need it to accept numbers only. here it is:

window.addEvent('domready', function() {
var name = new LiveValidation('text_14');
name.add( Validate.Length, {
minimum: 10,
maximum: 15,
wrongLengthMessage: 'Phone Number Must be between 10 & 15 characters'
});
});

would you please help me make proper changes?

thanks
GreyHead 06 Jan, 2011
Hi maxfard,

This is a snippet of JavaScript that uses the LiveValidation JavaScript library - it will not run without the library.

As it happens ChronoForms validation uses the same library and you can use the validate-number option to check for a number.

If you want a full custom validation then see the LiveValidation documents for the extra validations to add to check for digits (from memory it is Validate.Number).

Bob
billtemprybox 24 Mar, 2011
thank you, that answered my question as well :-)
dassad 19 Apr, 2011
Why don you use PHP for verification. Think that it's more reliable for verifiactions than JavaScript :p
This topic is locked and no more replies can be posted.