Change form input attribute I have form with an alt attribute like the following.

&lt;input type="text" alt="abc"&gt;


I want to replace that attribute with data-alt.

I tried the following code, but it doesn't seem to work. 

function theme_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    foreach($form["submitted"] as $newForm)
    {
        foreach($newForm as $keyid=&gt;$frmArr)
        {
            if(isset($frmArr[]["#attributes"]["alt"]))
            {
                    $alt = $frmArr["#attributes"]["alt"];
                    unset($newForm[$keyid]["#attributes"]["alt"]);
                    $newForm[$keyid]["#attributes"]["data-alt"] = $alt;
            }
        }
    }
}


The following code is not working either.

foreach($form["submitted"] as $newForm)
    {

        foreach($newForm as $keyid=&gt;$frmArr)
        {
            if($keyid=='#attributes'){
                $newForm[$keyid]['data-alt']=$newForm[$keyid]['alt'] ;
                 unset($newForm[$keyid]['alt'] );
                $form["submitted"]['#attributes']['alt'] = array("sss");
                form_set_value($form["submitted"]['#attributes']['alt'], array("aaa"), $form_state);
            }
        }


    }


What code should I use to achieve what I want?
function act_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'the_id_of_your_form') {
    unset($form['submitted']['#attributes']['alt']);
    $form['submitted']['#attributes']['data-alt'] = 'abc';
  }
}


Won't this work?