How to fetch form state value of a form on clicking custom mobile verification(required field in register form) button ajax based suppose I want to show mobile number(Form_state value) of form on clicking ajax based button named mobile verification. Here's the code:
if($form_id == 'user_register_form')
{
$form['mybutton'] = array(
'#type' => 'button',
'#name' => 'mybutton',
'#value' => 'Mobile Verification',
'#title' => t('Mobile Verification'),
//'#submit' => array('my_ajax_callback'),
'#prefix' => '<div id="dialog" title="Dialog Title" style="display:none;"><span class="close">X</span><div ><form action="#">
Enter OTP<br>
<input type="text" class="otp" name="otp" value="">
<br>
<input type="submit" class="otp_submit" value="Submit">
</form> </div></div>',
'#weight' => 19,
'#ajax' => array(
'event' => 'click',
'callback' => 'my_ajax_callback',
'method' => 'replace',
'wrapper' => 'form-wrapper',
),
);
}
function my_ajax_callback(&$form, &$form_state,$form_id) {
echo '<pre>';
print_r($form_state);
die;
// return $form;
}
In short i just want without saving form data can we show form_state value on clicking ajax based button in popup form.
The above code not working for me not able to get form_state value