Hints
In this Example explained about textarea component validation using Javascript.
getElementById() method using to get the Element. with selected element getting and setting the data using value attribute of Element Object in Javascript. focus() method of Element Object in Javascript used to set current cursor control to the Component.
|
TextareaValidationExample
<html>
<head>
<script type="text/javascript">
function validate(){
if (document.getElementById("txtarea_consolidation").value == ""){
alert("Enter the permanent address");
document.getElementById("txtarea_consolidation").focus();
}
else {
alert(document.getElementById("txtarea_consolidation").value);
}
}
</script>
</head>
<body>
<h2>Permanent Address</h2>
<textarea id="txtarea_consolidation"></textarea><br />
<button onclick="javascript:validate();" style="margin: 5px 0px;">Validate</button>
</body>
</html>
|