휴대폰 번호 확인
1400 단어 휴대폰 번호 확인
function _user_information_validate(&$form, &$form_state) {
if (empty($form_state['values']['field_phone']['und'][0]['value'])) {
form_set_error('account][field_phone', ' !');
}
$mobile = isset($form_state['values']['field_phone']['und'][0]['value']) ? $form_state['values']['field_phone']['und'][0]['value'] : '';
if(_user_is_mobile_exist($mobile)){
form_set_error('field_phone', ' ');
}
if((!preg_match("/^[\d]{11}+$/", $mobile) || drupal_substr($mobile, 0, 1) != 1) && !empty($mobile)){
form_set_error('field_phone',' ');
}
/**
*
*
* TRUE ,FALSE
*/
function _user_is_mobile_exist($mobile){
$query = new \EntityFieldQuery();
$count = $query
->entityCondition('entity_type', 'user')
->entityCondition('bundle', 'user')
->fieldCondition('field_phone', 'value', $mobile, '=')
->count()
->execute();
if($count > 0){
return TRUE;
}
else {
return FALSE;
}
}