Support

Home Forums Event Espresso Premium Registration Form Validation: Phone & Zip Code

Registration Form Validation: Phone & Zip Code

Posted: September 28, 2014 at 1:00 am

Viewing 7 reply threads


Bill Watson

September 28, 2014 at 1:00 am

I’m looking for a concrete solution, ideally a git repo reference or other very specific code example, to implement form validation for US Phone and US Zip Code inputs on EE4 Registration Forms.

I’ve found some older references on these forums to Jquery Validator, which I like a lot and use for other projects. However, the dynamic nature of the [name] and [id] attributes that EE4 assigns to reg form inputs requires more finesse than this lib offers out of the box.

Any answers from the support team?

Thanks!


Dean

September 29, 2014 at 4:38 am

Hi,

I thought it was weird that you couldn’t simply use the class that’s available (e.g. zip and phone). Looking closer it is possible though isn’t perhaps easily seen in the validation documentation.

I whipped up an example (and please note it is purely an example and will need to be refined) where it will validate the Zip and Phone for US styles using the jQuery Validation plugin:

https://gist.github.com/Apina/bc1b19ff2f3c3b73b369


Bill Watson

September 29, 2014 at 8:56 am

Thanks Dean! This looks great. Given the unique system-question classes + your remote calls to validation js, I think your code could work as-is for testing.

For testing, I don’t see an issue calling it on every page. Where would you add it to be most unobstrusive? functions.php? theme-functions.php? header.php?

Thanks for the support.


Lorenzo Orlando Caum

  • Support Staff

September 29, 2014 at 12:11 pm

Hi Bill,

For testing, a site specific plugin or your child themes functions.php file should be fine:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


Lorenzo


Bill Watson

September 29, 2014 at 12:16 pm

Ah, perfect. Thanks for the guidance gents!


Josh

  • Support Staff

September 29, 2014 at 2:04 pm

Hi Bill,

You can also add a check like this so your scripts only load where needed:

global $load_espresso_scripts;

if ( ! $load_espresso_scripts )
     return;

// load scripts here


Bill Watson

September 29, 2014 at 2:23 pm

Thanks Josh. From where would that check run? Same plug-in?


Lorenzo Orlando Caum

  • Support Staff

September 29, 2014 at 5:52 pm

Hi,

Here are two examples so you can see how it works:

https://eventespresso.com/topic/implementing-birth-date-date-picker-question/#post-118174

https://eventespresso.com/topic/seating-chart-add-on-query/#post-86812

Try this:

https://gist.github.com/Apina/bc1b19ff2f3c3b73b369#comment-1309263

Let us know if it works.


Lorenzo

Viewing 7 reply threads

The support post ‘Registration Form Validation: Phone & Zip Code’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso