Formtools - validate phone numbers?

27 views
Skip to first unread message

Mark Picker

unread,
Mar 25, 2014, 2:25:28 AM3/25/14
to farcr...@googlegroups.com
Hi,
 
I'm working on a frontend form that uses FormTools. Is there anything built into FC6 to validate Australian phone numbers or do I need to write something myself?
 
I need to allow for max 10 digits plus ( and ) and spaces (although ideally when it saves, I probably want to strip it back to just digits).
 
Cheers
Mark

Jeff Coughlin

unread,
Mar 25, 2014, 3:00:44 AM3/25/14
to farcr...@googlegroups.com
Mark,

My advice is to download the jquery validation plugin yourself and take a look at the additional-methods.js file and you'll see options for phoneUS, phoneUK, and mobileUK. Using that sample code (pretty simple) just create a new method for phoneAU. We use it for our frontend forms as well (but don't use formtools on frontend forms).

http://jqueryvalidation.org

Also, we like to use it in conjunction with the jQuery "Masked Input" plugin. We've been using it for over 4 years now and it works great. It's extremely flexible and very easy to use (Note: doesn't work on the frontend of the site when you're logged into FarCry due to a js conflict. Doesn't affect normal end users though so we never bothered to make a workaround).

http://digitalbush.com/projects/masked-input-plugin

Jeff

Mark Picker

unread,
Mar 26, 2014, 8:32:09 PM3/26/14
to farcr...@googlegroups.com
Hi Jeff,
 
Thank you for the reply.  I had found the validation plugin already in FC core but wasn’t sure if it was even being used or how to extend it from within a project.  Plus no point doing that if AU phone validation already existed in FormTools but I just couldn’t find it.  Sounds like I need to take the approach you suggest.
 
Can I ask why you don’t use FT’s for the frontend? Is it that you never had a need or do you have a problem with using them in the frontend? Just interested as I’ve been trying to use them more for frontend forms in the last 12 months but keep finding that I only get so far with them before it seems like FT starts to become more work than handcrafting from scratch myself.  This isn’t a negative comment about them in general as I know they are very powerful but I’m just finding that they are limited in the frontend.  Maybe they aren’t limited, but it’s just me or maybe the documentation needs some work?
 
Anyway thank you again Jeff.
 
Cheers
Mark
Reply all
Reply to author
Forward
0 new messages