Possible Duplicate:
Recommendation for javascript form validation library
In my HTML page there is a radio button, if that radio button is selected it will enable a div containing a textbox.
I need some validation here. If the checkbox is selected and textbox is empty then the submit button should not work and it should remain on the same page.
How can i implement this?
edited the code so that it will work now.
How can I implement this in Play! Framework?
This is a part of my code
<div id="ask-poll">
<form name="myform" action="@{Application.askquestion()}" onsubmit="return validateThisForm();">
<div class="wf-group">
<p><label for="questionText"><h3>Who do you want to ask for their opinion?</h3></label></p>
While this isnt a coded answer, there are a number of form validation javascript examples (hence Im not going to insult you by posting a bunch of links to them) where you can see how they use javascript to test if all the required elements are completed, eg, various “required” textboxes, a “have you read this” checkbox etc. You then implement this as part of the submit “onclick” and if its not valid you return “false” this prevents the form being submitted.