sseeley Posted June 5, 2009 Share Posted June 5, 2009 I am trying to validate a check box, but my return always just come back with 'on'. Can anyone help me? <head> <script> <!-- function validate() { var deleted=document.getElementById("del").value alert(deleted); } --> </script> </head> <?php echo "<form action=\"test1.php\" method=\"POST\" name=\"paymentsForm\" onsubmit=\"return validate()\">"; echo "<input type=\"checkbox\" name=\"deleted\" id=\"del\"></td>"; echo "<input type = \"submit\">"; echo "</form>"; ?> Many thanks in advance Quote Link to comment Share on other sites More sharing options...
Axeia Posted June 5, 2009 Share Posted June 5, 2009 Not quite sure what you're trying to do, but you need to add a return value to the validate function. 'return true' when it does what you want. 'return false' when it doesn't do what you want, so it doesn't get submitted. Quote Link to comment Share on other sites More sharing options...
sseeley Posted June 5, 2009 Author Share Posted June 5, 2009 I just want the validate to alert me and the form to tell me what the status of the checkbox is? Whether it is 'Checked' or 'Not Checked'. It is just a test form Quote Link to comment Share on other sites More sharing options...
Axeia Posted June 5, 2009 Share Posted June 5, 2009 function validate() { var deleted=document.getElementById("del").checked; alert(deleted); return false; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.