Monday, November 23, 2009

Validation in Javascript

21.Validation
This is easiest way to validate text box using javascript. when we click on submit button the javascript check the text box, if didn’t enter any value in the text box it will show FILL THE USER NAME otherwise the page login successfully.

< input id="fname_id" type="text" / >
< input onclick="validation()" type="submit" value="Submit" / >
< script type="text/javascript" >
function validation()
{
if(document.getElementById("fname_id").value=="")
{ alert("FILL THE USER NAME"); }
else { alert("successfully login"); }
}
< / script >

No comments:

Post a Comment