DEMO : Validation of Listbox on submit of a Form


Submit the form by clicking the button.



Return to Listbox validation

JavaScript

<script type="text/javascript">
function data_check()
{
var str=document.getElementById("l1").value;
if(str.length <=0){
document.getElementById('my_msg').innerHTML=" Select One option before submitting ";
return false;
}else{
document.forms['drop_list'].submit();// Submit the form}
}
}
</script>

HTML

<form name="drop_list" action="listbox-validation-demock.php" method="post" id='f1'>
<select name="Category" id="l1">
<option value=''>Select One</option>
<option value="PHP">PHP</option>
<option value="ASP">ASP</option>
<option value="JavaScript">JavaScript</option>
<option value="HTML with design">HTML</option>
<option value="Perl">Perl</option><option value="MySQL">MySQL</option></select>
<br>
<div id='my_msg'>Submit the form by clicking the button.</div>
<br>
<input onclick="data_check()"; value="Submit Form" type="button"> 

</form>

Listbox Validation
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer