Practical 3 : Write a JavaScript Code for take two textbox ,one
button and enter value into text box if textbox is null then print
message �Enter the Text�
<html>
<head>
<title>Validation Example</title>
<script type="text/javascript">
function chk_txt()
{
if (document.f1.txt1.value=="")
{
alert("Plz. Enter First Value");
document.f1.txt1.focus();
return false;
}
if (document.f1.txt2.value=="")
{
alert("Plz. Enter Second Value");
document.f1.txt2.focus();
return false;
}
}
</script>
</head>
<body>
<center>
<form name="f1">
<table border="1px">
<tr>
<td>Enter First Value : </td>
<td><input type="text" name="txt1"></td>
</tr>
<tr>
<td>Enter Second Value : </td>
<td><input type="text" name="txt2"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="b1" value="Click Here" onClick="chk_txt()">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>

EmoticonEmoticon