DEMO : Validation of Listbox on submit of a Form
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
This article is written by plus2net.com team.
plus2net.com