jenny
jenny

Reputation: 11

Javascript form reset

I use this code to reset my radio buttons, but it doesn't reset my text fields. How can I make it reset my text fields?

function rensa(obj)
{
    for(var i=0; i<obj.length; i++)    
         obj[i].checked = false;

}

Upvotes: 0

Views: 1358

Answers (3)

sushil bharwani
sushil bharwani

Reputation: 30197

function rensa(obj)
{
    for(var i=0; i<obj.length; i++){    
         obj[i].checked = false;
         obj[i].value = "";
  }

}

Upvotes: -1

amal
amal

Reputation: 1369

The Form element has a reset() method

Upvotes: 1

Prisoner
Prisoner

Reputation: 27628

Why don't you just use reset(), e.g.:

document.myform.reset();

Upvotes: 7

Related Questions