Update form attributes with javascript and get them on submit Hi i have a textfield form with attribute of "data-updated" the default is 0
If user clicks on textfield and fill it, "data-updated" changes to 1 with jQuery.
On form submit the attribute remains 0 even if it changed to 1, how can i fix it?

Here is the code:

    $form['name'] = array(
        '#title' =&gt; t('Name'),
        '#type' =&gt; 'textfield',
        '#attributes' =&gt; array('data-updated' =&gt; 0, 'onclick' =&gt; array('jQuery(this).attr("data-updated", 1);')),
    );


And here is the submit

print_r($form_state['complete form']['name']['#attributes']['data-updated']);
die();


I always get 0 even if the jQuery update the attribute to 1 :/
As Clive said in the comment, you can't fix it. To do such things in the background of a form, use a hidden element:

https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#hidden