I am going to use javascript to validate my radio buttons. What I need to do is that I want to use document.write so that the validation message appears in the <div> "radioalert" but I don't know how to do this. Instead it is displaying the message as its own on the page.
Below is javascript function to check radio buttons:
below is my form:Code:function validation(){ if(sessionform.sessionNo[0].checked==false && sessionform.sessionNo[1].checked==false && sessionform.sessionNo[2].checked==false && sessionform.sessionNo[3].checked==false && sessionform.sessionNo[4].checked==false){ document.write("Please select the Number of Sessions you Require");return false ;}
Code:<form action="create_session.php" method="post" name="sessionform"> <table> <tr> <th>2: Number of Sessions :</th> <td class="sessionNo"><input type="radio" name="sessionNo" value="1" />1</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="2" />2</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="3" />3</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="4" />4</td> <td class="sessionNo"><input type="radio" name="sessionNo" value="5" />5</td> </tr> </table> <p><strong>9: </strong><input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="validation()" /></p> <div id="radioalert"></div> </form>



Reply With Quote


Bookmarks