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 2 of 2

Thread: Combox Question

  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    Combox Question

    Hi There,

    I need your help.

    What would be the Javascript code,

    to check a if a selection has been made in a particular combox? and if a selection has not been made, to alert the user that they must select a value from the drop down box.

    Much thanks and appreciation for all your help.

    Cheers,

    Jason

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,776
    Thanks
    19
    Thanked 155 Times in 146 Posts
    something like the following:

    Code:
    <form onsubmit="return validate(this);">
    	<select>
    		<option value="default">select a value</otion>
    		<option value="sdasdf">sdasdf</otion>
    		<option value="sdasdf">sdasdf</otion>
    		<option value="sdasdf">sdasdf</otion>
    	</select>
    	<input type="submit" value="submit" />
    </form>
    
    <script type="text/javascript">
    	function validate(formObj)
    	{
    		if (formObj.getElementsByTagName('select')[0].value == 'default')
    		{
    			alert('you must select a value from the drop down menu');
    			return false;
    		}
    		return true;
    	}
    </script>
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

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