when no value is specified in the "roll" input field, a warning is generated by the "empty ()" function, but this empty value is still passed to "retrive.php", so how to stop it and just go through value to 'retrive'. php when some input value is provided.
<html> <head> <title>STUDENT FORM</title> <script type="text/javascript"> function empty() { var x; x = document.getElementById("roll-input").value; if (x == "") { alert("Enter a Valid Roll Number"); }; } </script> </head> <body > <h1 align="center">student details</h1> <div id="input"> <form action='retrive.php' method='get'> <fieldset> <legend>Get Details</legend> <dl> <dt><label for="roll-input">Enter Roll Number</label></dt> <dd><input type="text" name="roll" id="roll-input"><dd> <input type="submit" value="submit" onClick="empty()" /> </dl> </fieldset> </form> </div> </body> </html>
javascript
Pawan
source share