views:

35

answers:

2

my html code-

 <form method="post" name="editorform" id="editorform" onsubmit="return validate_editorform(this)" action="#">
      <ol><li>
        <label for="qtitle"><b>Title</b></label>
        <input id="qtitle" name="qtitle" class="text"></textarea>
      </li><li>
        <label for="tag"><b>Tag</b></label>
            <table border="0">
                <tr>
                    <td><input type="radio" name="tag" value="art"/>Art & Living</td>
                    <td><input type="radio" name="tag" value="travel" class="rdbtn"/>Travel</td>
                    <td><input type="radio" name="tag" value="religion" class="rdbtn"/>religion</td>
                </tr>
.....

my javascript-

function validate_editorform(editorform) 
{
    var qtitle = editorform.qtitle.value;
    var tag = editorform.tag.value;  
    var question = editorform.question.value;
    var nameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/; 

    if(qtitle == "") {
        inlineMsg('qtitle','You must enter a Question title.',5);
        return false;
    }
    if(editorform.tag.checked == "") {
        inlineMsg('tag','You must Tag your question.',5);
        return false;
    }
    if(question == "") {
        inlineMsg('question','You must enter a your Question.',5);
        return false;
    }
}

For qtitle and question JavaScript is working fine but for radio button (tag) it isn't. Can anyone identify the problem?

A: 

Change

if(editorform.tag.checked == "") {

to

if(tag == "") {
Andy E
+1  A: 
if(editorform.tag[0].checked == False... and so on for tag[1]...)
nectar
ya now its working fine...thanks
amanda