how to add #states property to an $element of the custom field? i develop a custom field and have some errors on property #states.

The method of using #states in $element is quiet different with the $form.

The code i write is below.

 function cellphonefield_field_widget_form(&amp;$form,&amp;$form_state,$field,$instance,$langcode,$items,$delta,$element)
    {
        $base=$element;

        $element['cellphone']=array(
         '#type' =&gt; 'textfield',
         '#title'=&gt;t('Enter your Cell phone Number!'),
         '#description'=&gt;t('System will send you a message '),
         '#default_value'=&gt;isset($items[$delta]['cellphone'])?$items[$delta]['cellphone']:'test for this field',
         '#weight'=&gt;0,
        )+$base;

      $element['send_sms']=array(
         '#type' =&gt; 'button',
         '#name'=&gt;'send_sms',
         '#title' =&gt; t('validate your cellphone number'),
         '#weight'=&gt;1,
         '#value'=&gt;t('Send the validation code!'),
         '#ajax'=&gt;array(
            'callback'=&gt;'ajax_send_sms_callback_function',
            'wrapper'=&gt;'replace_markup_to_textfield',
            'effect'=&gt;'fade',
            'speed'=&gt;'fast',
            'method'=&gt;'replace',
         ),
         '#states'=&gt;array(
            'disable'=&gt;array(
              ':input[name="profile_main[field_cellphone][und][0][cellphone]"]'=&gt;array('filled'=&gt;TRUE),   
            ),
         ),
        );

    $element['validation_fieldset']=array(
    '#type'=&gt;'markup',
    '#weight'=&gt;2,
    '#prefix'=&gt;'&lt;div id="replace_markup_to_textfield"&gt;',
    '#suffix'=&gt;'&lt;/div&gt;',
  );

   return $element;
}


No matter what i replace the input name of the #states, it's still not working.

i checked the html form and the code blow

&lt;input type="text" id="edit-profile-main-field-cellphone-und-0-cellphone" name="profile_main[field_cellphone][und][0][cellphone]" value="" size="60" maxlength="128" class="form-text" /&gt;


what could the problem be?
drupal_process_states() takes the parameter $elements and contains the example:

array(
  'visible' =&gt; array(
    ':input[name="remote_checkbox"]' =&gt; array('checked' =&gt; TRUE),
  ),
)


Your example is very similar:

array(
  'disable'=&gt;array(
    ':input[name="profile_main[field_cellphone][und][0][cellphone]"]'=&gt;array('filled'=&gt;TRUE),   
   ),
 )


But I noticed that 'visible' is an adjective while 'disable' is a verb so I checked the list of available states on the drupal_process_states() documentation and found:


  The following states may be applied to an element:
  
  
  enabled
  disabled
  required
  optional
  visible
  invisible
  checked
  unchecked
  expanded
  collapsed
  


So it looks like your problem boils down to a missing letter 'd' on 'disabled'.