Tuesday, April 26, 2011

PHP validation for radio button


Baru tau rupe2nye.. validation utk textfield tak same dgn validation utk radio button.. patut lah puas buat memula tak jadi2... huhu... =D


function survey()
{
//validation untuk textfield
if (document.form1.position.value == "")
{
alert("Please insert your position");
document.form1.position.focus();
return false;
}

//validation utk radio button (lebih dari 1 radio button yg sama nama)
if (( document.form1.speed[0].checked == false )&&
( document.form1.speed[1].checked == false )&&
( document.form1.speed[2].checked == false )&&
( document.form1.speed[3].checked == false )&&
( document.form1.speed[4].checked == false ))
{
alert("Please tick your question number 1");
return false;
}
}

0 comments:

Post a Comment