
my problem is following code is my form i want validation and for email field it will check formate useing regularexpressions.
<html>
<script src="combovalidate1.js" type="text/javascript" language="javascript">
</script>
<body>
<form name="form" method="post" onsubmit="return validate1();">
<table align="center" border="1px" bgcolor="orange" >
<tr>
<td>Enter Name</td>
<td><input type="text" name="name">
</td>
</tr>
<tr>
<td>email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Enter Address</td>
<td><textarea rows="4" cols="4" name="address"></textarea>
</td>
</tr>
<tr>
<td>Country:</td>
<td><select name="combo1" onchange="change(this);">
<option value="0">-select-</option>
<option value="1">India</option>
<option value="2">USA</option>
<option value="3">UK</option>
</select>
</td>
</tr>
<tr>
<td>State:</td>
<td><select name="combo2"></select></td>
</tr>
<tr>
<td><input type="submit" value="Submit">
</td>
<td><input type="reset">
</td>
</tr>
</table>
</form>
<body>
<html

<html>
Email Validation
<script language = "Javascript">
function checkEmail() {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)){
document.write("You have entered valid email.");
return true;
}
return false;
}
function ValidateEmail(){
var emailID=document.form.email;
if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (checkEmail(emailID.value)==false){
emailID.value=""
alert("Invalid Email Adderess");
emailID.focus()
return false
}
return true
}
</script>
<form name="form" method="post" onSubmit="return ValidateEmail()">
Enter an Email Address : <input type="text" name="email" size="30"><br>
<input type="submit" name="Submit" value="Submit">
</form>
</html>

validation for name it is useful try it..
<html>
<head>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm()" method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>
......
for email address it is usefull..Try it..
<html>
<head>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>
</html>
do well
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.