In Association with Amazon.in   Flipkart

Tuesday, November 19, 2013

JavaScript To Display Error Message After the Form Object Example

JavaScript To Display Error Message After the Form Object:

Example:

<script>
function check()
{
if(document.getElementById('sid').value=="")
{
document.getElementById('stxt').innerHTML="* Enter any Search Key word";
document.getElementById('stxt').style.color="red";
document.getElementById('sid').style.backgroundColor="yellow";
}
else
alert("Searching Result...");
}
</script>
</head>
<body>
<input type="text" name="searchtxt" id="sid" /><span id="stxt">*Require</span>
<br/>
<input type="button" value="Search" onClick="check()" />

</body>

Output:
*Require

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...