<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Form</title>
</head>
<body>
<form action="#" name="form" onsubmit="validate()">
Name : <input type="text" name="name" /><br />
Email : <input type="text" name="email" /><br />
Pin : <input type="text" name="pin" /><br />
Country: <select name="country">
<option value="1" >USA</option>
<option value="2" >UK</option>
<option value="3">India</option>
</select>
<input type="submit" value="submit" />
</form>
<script type="text/javascript">
function validate()
{
if (document.form.name.value == "")
{
alert(" Enter a name ");
return false;
}
if (document.form.email.value == "")
{
alert(" Enter a mail id ");
}
if (document.form.pin.value == "");
{
alert(" Enter a pin ");
}
if (document.form.country.value == "");
{
alert(" country");
}
}
</script>
</body>
</html>
OUTPUT:
No comments:
Post a Comment