Question

Hi I'm a relative beginner. I need each object in my form to be validated and basically I don't know how to validate a drop-down menu. Here is my HTML, thanks guys.

<div id="valAlert"></div>
        <form name="review" onsubmit="return validateForm()">
            <div id="valAlert"></div>
                <fieldset>
                    Title: <input type="text" name="Title"><br/>
                    Email Address: <input type="text" name="Email"><br/>
                    Rating: <select name="Rating">
                    <option value="0"></option>
                        <option value="1">Excellent</option>
                        <option value="2">Good</option>
                        <option value="3">Bad</option>
                        <option value="4">Awful</option>
                        </select><br/>
                    <textarea name ="Comments" rows="8" colspan="40">Comments: </textarea>
                    </fieldset>
                    <fieldset>
                        <input class="button" type="submit"  value="Submit"/>
                    </fieldset>
        </form>
Était-ce utile?

La solution

     `else if (r=="0"){

document.getElementById("valAlert").innerHTML="We require a rating"; return false; } `

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top