Showing posts with label Null validation in Java script. Show all posts
Showing posts with label Null validation in Java script. Show all posts

Tuesday, September 1, 2009

Check null field using getElemenytById in Java script.


<script type='text/javascript'>
function notEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus();
return false;
}
return true;
}
</script>
<form>
Employee Name: <input type='text' id='req1'/>
<input type='button'
onclick="notEmpty(document.getElementById('req1'), 'Employee Name should not be empty')"
value='Submit' />
</form>