Hello All,
I am trying to use regular expression for us phone numbers
I have tried this one
http://www.chronoengine.com/forums.html?cont=posts&f=2&t=13323&start=0&hilit=regular+expression#p27589
But got no success.
i tried the code in mooValidation.js and use class="validate-phone-us"
I think forms are using jsvalidation2.js .
Plz tell me how I can use regular expression for phone no. xxx-xxx-xxxx
I am trying to use regular expression for us phone numbers
I have tried this one
http://www.chronoengine.com/forums.html?cont=posts&f=2&t=13323&start=0&hilit=regular+expression#p27589
But got no success.
i tried the code in mooValidation.js and use class="validate-phone-us"
I think forms are using jsvalidation2.js .
Plz tell me how I can use regular expression for phone no. xxx-xxx-xxxx
Hi Lara_Shadow,
Please re-read the post you linked to. The code went into the Form JavScript box. No need to hack any files.
Bob
Please re-read the post you linked to. The code went into the Form JavScript box. No need to hack any files.
Bob
I am using this in Form Java Script
and this in HTML
Now getting
Validation.add('validate-phone-us', 'Please enter a valid phone number xxx-xxx-xxxx', function(v) {
var regex = /^\d{3}-\d{3}-\d{4}$/;
return Validation.get('IsEmpty').test(v) || regex.test(v);
});
and this in HTML
<input class="validate-phone-us" maxlength="150" size="30" title="Please enter in the formate xxx-xxx-xxxx" id="text_3" name="text_3" type="text" />
Now getting
Validation is not defined
error
Hi Lara_Shadow,
Sounds as though the ChronoForms validation files aren't being loaded. Try setting 'Load ChronoForms css/Js Files' to yes and/or setting Validation 'On' in the validation tab.
Bob
Sounds as though the ChronoForms validation files aren't being loaded. Try setting 'Load ChronoForms css/Js Files' to yes and/or setting Validation 'On' in the validation tab.
Bob
Actually both are set to YES
Following the snap shot from fire bug.
Showing error on line no 92
It is showing my JS validation in CDATA.
Following the snap shot from fire bug.
Showing error on line no 92
It is showing my JS validation in CDATA.
Hi Lara_Shadow,
Ah, thanks, looks as though we need to delay the validation until the other code has loaded. Put this wrapper round the script and see if that does the trick:
Bob
Ah, thanks, looks as though we need to delay the validation until the other code has loaded. Put this wrapper round the script and see if that does the trick:
window.addEvent('domready', function() {
Validation.add('validate-phone-us', 'Please enter a valid phone number xxx-xxx-xxxx', function(v) {
var regex = /^\d{3}-\d{3}-\d{4}$/;
return Validation.get('IsEmpty').test(v) || regex.test(v);
});
});
Bob
Now I getting this one error message.
Hi Lara_Shadow,
My apologies, the script I posted was for an old version of ChronoForms using a different validation library.
This script works OK with the present version:
[attachment=0]18-07-2010 16-06-28.png[/attachment]
Bob
My apologies, the script I posted was for an old version of ChronoForms using a different validation library.
This script works OK with the present version:
window.addEvent('domready', function() {
var phone = new LiveValidation('phone');
phone.add(Validate.Format, {
pattern: /^\d{3}-\d{3}-\d{4}$/,
failureMessage: 'Please enter a valid phone number'
});
});
The input in the Form HTML is <input class="cf_inputbox" maxlength="150" size="30" title="" id="phone" name="phone" type="text" />
and the result is:[attachment=0]18-07-2010 16-06-28.png[/attachment]
Bob
This topic is locked and no more replies can be posted.