CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Field validation for email, postal code, phone XXX-XXX-XXXX
Pages: [1]

Author Topic: Field validation for email, postal code, phone XXX-XXX-XXXX  (Read 1708 times)

mcnamedia

  • Guest
Field validation for email, postal code, phone XXX-XXX-XXXX
November 04, 2008, 06:40:53 am
Hi I've been looking around the forums and have found a couple of subjects on this but nothing recent that's definitive.

When a person registers for an event, I'd like to validate the fields for

email (something@something.com)
phone - xxx-xxx-xxxx
fax - same thing

Can someone point me in the right direction?

Thanks,
Greg

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Field validation for email, postal code, phone XXX-XXX-XXXX
November 04, 2008, 06:57:23 am

you will need to implement a validate hook for the additional fields validation

check:

http://issues.civicrm.org/jira/browse/CRM-2480

For joomla, you will need to create a function: joomla_civicrm_validate and ensure the file is loaded when civicrm calls the function

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Field validation for email, postal code, phone XXX-XXX-XXXX
May 14, 2010, 09:17:30 am
sample code for e-mail address on a contribution page

function grammy365_membership_civicrm_validate( $formName, &$fields, &$files, &$form ) {
    $session =& CRM_Core_Session::singleton();
    $contactId = $session->get( 'view.id' );
    switch ($formName) {
      case 'CRM_Contribute_Form_Contribution_Main': //Contribution Page
   if (isset($fields['email-5'])) {
     $email = $fields['email-5'];
     if (valid_email_address($email) != TRUE) {
       $errors['email-5'] = ts( "The e-mail appears to be invalid" );
     }    
   }
        break;
    }
  return empty( $errors ) ? true : $errors;
}
http://www.rootyhollow.com

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Field validation for email, postal code, phone XXX-XXX-XXXX

This forum was archived on 2017-11-26.