Cell Phone Validation field using sms message I recently want to develop a field for user account.

The Field will provide a cellphone textfield and a validate button!

After finishing the cellphone textfield by the user, The user push the validate button.

Then, the system will send the sms message using ajax.

After sending the validate code message to the user, the system will respond the CODE to the client side. However, the cell phone textfield is invisible right now.



Finally,the user enter the code get from sms message and then push the button.

The system will check the code by ajax and then return the correct/false value to the client side.

After the steps above, the system will hide all the field and show the result of the validation.


My question is how can I do that?
You don't want to create this yourself. You want to use the relatively new Two-Factor Authentication Module and it's plugins -- or create your own plugin.


  Second-factor authentication for Drupal sites. Drupal provides
  authentication via something you know -- a username and password while
  TFA module adds a second step of authentication with a check for
  something you have -- such as a code sent to (or generated by) your
  mobile phone.
  
  TFA is a base module for providing two-factor authentication for your
  Drupal site. As a base module, TFA handles the work of integrating
  with Drupal, providing flexible and well tested interfaces to enable
  your choice of various two-factor authentication solutions like
  Time-based One Time Passwords (TOTP), SMS-delivered codes,
  pre-generated codes, or integrations with third-party services like
  Authy, Duo and others.
  
  Features
  
  
  Pluggable - Supports multiple methods of 2nd factor verification and
  can work with any number of 3rd party systems
  Configurable - Supports fallback methods and context-specific exceptions
  Flood control and even secures one-time logins
  Tested - Over 100 tests
  
  
  TFA module is recommended as a full suite solution to 2nd factor authentication and Drupal.
  
  See the TFA basic plugins for a TOTP plugin that works with FreeOTP,
  Google Authenticator, Authy, and any other app that works with TOTP
  tokens.
  
  This module stores some sensitive data which it encrypts using the php
  mcrypt library. You will need to have the mcrypt extension installed
  to use the module.


This module is designed to allow you to meet your use-case (some custom code may be required). It's also designed with fallbacks and edge-cases taken into consideration which you may not have thought of -- and it has a zillion tests.