drupal adding onchange event to node form

Posted by Arun on Stack Overflow See other posts from Stack Overflow or by Arun
Published on 2010-05-18T08:08:57Z Indexed on 2010/05/18 8:10 UTC
Read the original article Hit count: 194

Filed under:
|

hi i need to know how to add attribute onchange to a custom content_type field?

For ex my content_type has 2 fields phone (name:field_phone[0][value], id:edit-field-phone-0-value),email (name:field_email[0][value], id:edit-field-email-0-value). i'm unable to add attribute as follows.

 function knpevents_form_event_node_form_alter(&$form, &$form_state) { 

   $form['title']['#attributes'] = array('onchange' => "return titlevalidate(0)");//fine
   $form['field_evt_org[0][value]']['#attributes']= array('onchange' => "return organiservalidate(0)"); //error
   $form['field_evt_org[0][value]']['#attributes']= array('onchange' => "return organiservalidate(0)"); //error
 }

how to add it

© Stack Overflow or respective owner

Related posts about drupal

Related posts about form