0

I have following validation working for text field

function check(){

    var flag = 0;
    if(document.form1.namef.value == ""){
        document.form1.namef.style.backgroundColor='#FF9ECE';
        flag = 1;
    }
    else{
        document.form1.namef.style.backgroundColor='';
    }if(flag){
        return false;
    }
    else{
        return true;
    }

}

I have a form with gender which is not working in validation

<th width="222">Gender<font size="1" color="red">*</font></th>
                    <td width="253"><input type="radio" name="sex" value="0">Male<input type="radio" name="sex" value="1">Female</td>

How can I validate radio button in the function check()?

Just code
  • 13,553
  • 10
  • 51
  • 93
  • http://stackoverflow.com/questions/9618504/get-radio-button-value-with-javascript ... Follow this to get the radio button value, then just do whatever you need to do.. – briosheje Mar 25 '14 at 08:15
  • Why not have `flag` as a boolean and return that? – Class Mar 25 '14 at 08:18

0 Answers0