Validation on user registration form ?

Posted by Nitz on Stack Overflow See other posts from Stack Overflow or by Nitz
Published on 2010-05-04T12:26:52Z Indexed on 2010/05/04 12:28 UTC
Read the original article Hit count: 194

Filed under:
|
|
|

Hey Guys,
i have made module in which i am trying to add validation like if the user had entered the characters in "Phone No" text filed and same on "Mobile No".
This will run when user had open the user registration form.
I have made this....

<?php
function form_intro_form_alter(&$form,&$form_state,$form_id){
    if($form_id == 'user_register' || $form_id == 'user_edit'){
        $form['Personal Information']['profile_pno']['#validate'] = array('form_intro_pno_validate' => array());   //profile_pno is for Phone No.
        $form['Personal Information']['profile_mno']['#validate'] = array('form_intro_mno_validate' => array());   //profile_mno is for Mobile No.
    }
}


function form_intro_pno_validate($element){
    if(!is_numeric($element['#value'])){
        form_set_error('profile_state' , t('Please Enter Only Number in Phone no'));
    }
}

function form_intro_mno_validate($element){
    if(!is_numeric($element['#value'])){
        form_set_error('profile_state' , t('Please Enter Only Number in Mobile no'));
    }
}
?>

the module name is form_intro.....
plz check it and send me replay...
this isn't working...it not giving any error when user had entered the characters.

© Stack Overflow or respective owner

Related posts about drupal

Related posts about drupal-6