ChronoEngine Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Validate US Phone Number and Zipcode for dummies (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 1
TOPIC: Validate US Phone Number and Zipcode for dummies
#7839
chrono1 (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Validate US Phone Number and Zipcode for dummies 2 Months, 1 Week ago Karma: 0  
I've been dinking for days on how to validate a proper US phone number and zip code. I finally think I have it.

First, add this code to validate.js (if you can't find the file, don't even do this!) I'm not an expert on JavaScript, so I hacked and bashed the comma's and all that.

Code:

['validate-phone', 'Please enter a valid US Phone Number. (xxx)xxx-xxxx', function(v) { return Validation.get('IsEmpty').test(v) || /^(\()?(\d{3})([\)-\. ])?(\d{3})([-\. ])?(\d{4})$/.test(v) }], ['validate-postal', 'Please enter a valid US zip code or Canadian postal code.', function(v,elm) { v = v.toUpperCase(); var regex = /((^\d{5}([- |]\d{4})?$)|(^[A-Z]\d[A-Z][- |]\d[A-Z]\d$))/; if(Validation.get('IsEmpty').test(v) || regex.test(v)){ $(elm).value = v; return true; } return false; }],
In the back end, pick Validate "Yes" from the validation tab. Use "Prototype" as this will cause validate.js to call in the HEAD. Next, don't put any fields in the Validation tab. For some reason, it screws it up. Use class="validate-postal" and class="validate-phone" and the other old-school ways to call validation. Someone might prove me wrong on some of this. I haven't spent the time to completely test all the scenarios. It's working nicely for me following these rules. Hope this saves someone some time. I sure wish someone would add phone and postal validation to the Validation tab. Not me!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#7878
admin (Admin)
Admin
Posts: 1570
graphgraph
User Online Now Click here to see the profile of this user
Re:Validate US Phone Number and Zipcode for dummies 2 Months, 1 Week ago Karma: 22  
Thanks!
 
Report to moderator   Logged Logged  
 
ChronoForms Developer Thanks for using ChronoForms.
If you have any problems with ChronoForms please tell us.
If you like ChronoForms please post a review at Joomla.org
  The administrator has disabled public write access.
#7887
GreyHead (Admin)
Admin
Posts: 2809
graph
User Offline Click here to see the profile of this user
Re:Validate US Phone Number and Zipcode for dummies 2 Months ago Karma: 59  
Hi chrono,

Google is your friend. There's a Google Group for Andrew Tetlaw's validation code (the code ChronoForms uses) and you'll find a phone number validation here

Bob
 
Report to moderator   Logged Logged  
 
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
  The administrator has disabled public write access.
#7985
chrono1 (User)
Fresh Boarder
Posts: 4
graphgraph
User Offline Click here to see the profile of this user
Re:Validate US Phone Number and Zipcode for dummie 2 Months ago Karma: 0  
Thanks for the link to the Google groups! Awesome! Maybe that should be the "how to"!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#7987
GreyHead (Admin)
Admin
Posts: 2809
graph
User Offline Click here to see the profile of this user
Re:Validate US Phone Number and Zipcode for dummie 2 Months ago Karma: 59  
Hi Chrono1,

I've added it to a FAQ.

Bob
 
Report to moderator   Logged Logged  
 
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
  The administrator has disabled public write access.
#8032
Sapient (User)
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Re:Validate US Phone Number and Zipcode for dummie 1 Month, 4 Weeks ago Karma: 2  
I am able to get this to work with the phone number. I was wondering if anyone can explain why we are not able to have a required field along with the validation?

Is there syntax that we can add to the actual form code that would require a specific field to be required thus bypassing the validation tab all together?

Thanks,
Brian
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop


equalheight If you have any questions you can post to our forums and we will be glad to help ASAP

Members Login






Lost Password?
No account yet? Register

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for
goods and services provided by ChronoEngine.com

ChronoForms License

equalheightTo be able to continue working at this component we decided to get a small profit out of it but at the same time don't force everybody to pay in order to use this great component.

 

 From version 1.5 and up a link at the bottom of everyform created will be placed, saying "joomla professional work", the link will be to us here htttp://www.chronoengine.com, its illegal to remove this link from the source code unless you have a license,

so the license is very simply for the same ChronoForms component without a link, thats all!

This License is for 5 different websites ONLY. 

 

 However, in order to allow everybody to still use the component and even get out of this, the link is inside a div with class : chronoform , use this to hide the link by using different colors or whatever if you really can't pay, but of course the link is still exists at your page source.

 

The license is ONLY 25$ can be bought here :

 

Thank you!

 

ChronoEngine.com Team 

Joomla Templates and Joomla Tutorials