Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Form validator Issue

    I have the following code that validates a select box I have. It works but I want to change it to check two select boxes and also it still submits the form after the alert comes up.

    Code:
    <input name="submit" type="submit" value="Post Question" onclick="madeSelection(document.getElementById('forums'), 'Please Choose a forum sub category')" />
    Code:
    <script type='text/javascript'>
    function madeSelection(elem, helperMsg){
    	if(elem.value == 'Please Choose'){
    		alert(helperMsg);
    		elem.focus();
    		return false;
    	}else{
    		return true;
    	}
    }
    </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    <input name="submit" type="submit" value="Post Question" onclick="return madeSelection(document.getElementById('forums'), 'Please Choose a forum sub category')" />

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post
    How can I make it so that it will validate two select boxes?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •