wood burning stoves 2.0
The moose likes HTML, CSS and JavaScript and the fly likes why my email validation is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "why my email validation is not working " Watch "why my email validation is not working " New topic

why my email validation is not working

raj talatam
Ranch Hand

Joined: Apr 19, 2012
Posts: 90
please change the code to validate email

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script language="javascript">
function validate(){
var name=document.form.name.value;
var city=document.form.city.value;
var category=document.form.category.value;
var email=document.form.email.value;
var phone=document.form.phone.value;
var mobile=document.form.mobile.value;
var fax=document.form.fax.value;
var state=document.form.state.value;
var contactperson=document.form.contactperson.value;
var website=document.form.website.value;
var govcernumber=document.form.govcernumber.value;
var estayear=document.form.estayear.value;
var ranking=document.form.ranking.value;
var timings=document.form.timings.value;
var address=document.form.address.value;
var pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

alert("Enter Username!");
return false;
alert("Enter city!");
return false;
alert("Enter category!");
return false;
if (pattern.test(email)) {
alert("Please enter a valid email Id");
return false;

alert("Enter phone!");
return false;
alert("Enter mobile!");
return false;
alert("Enter fax!");
return false;
alert("Enter state!");
return false;
alert("Enter contactperson!");
return false;
alert("Enter website!");
return false;
alert("Enter govcernumber!");
return false;

alert("Enter estayear!");
return false;
alert("Enter ranking!");
return false;
alert("Enter timings!");
return false;

alert("Enter address!");
return false;

return true;

<form name="form" method="post" action="/companydeatails/store.jsp" onsubmit="javascript:return validate();onClick=
<tr><td>name:</td><td><input type="text" name="name"></td></tr>
<tr><td>city:</td><td><input type="text" name="city"></td></tr>
<tr><td>category:</td><td><input type="text" name="category"></td></tr>
<tr><td>email:</td><td><input type="text" name="email"></td></tr>

<tr><td>phone:</td><td><input type="text" name="phone"></td></tr>
<tr><td>mobile :</td><td><input type="text" name="mobile"></td></tr>
<tr><td>fax:</td><td><input type="text" name="fax"></td></tr>
<tr><td>state:</td><td><input type="text" name="state"></td></tr>
<tr><td>contactperson:</td><td><input type="text" name="contactperson"></td></tr>
<tr><td>website:</td><td><input type="text" name="website"></td></tr>
<tr><td>govcernumber:</td><td><input type="text" name="govcernumber"></td></tr>
<tr><td>estayear:</td><td><input type="text" name="estayear"></td></tr>
<tr><td>ranking:</td><td><input type="text" name="ranking"></td></tr>
<tr><td>timings:</td><td><input type="text" name="timings"></td></tr>
<tr><td>address:</td><td><input type="text" name="address"></td></tr>

<tr><td></td><td><input type="submit" value="Login"></td></tr>
<tr><td></td><td><a href="form.jsp">Register Here</a></td></tr>
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

rajendar talatam wrote:please change the code to validate email

Rajendar, when you ask for help in forums which are volunteer driven, you are expected to ShowSomeEffort in asking your question. Your post doesn't even explain the issue you are running into. Dumping random HTML or other code and asking others to change it to get it working isn't the right way to ask for help. If you really do need help, please take some time to add more details about the issue you are running into and form a proper question. Also while posting code, logs, xml content or other similar content, please use the code blocks to wrap that text (you can use the Code button in the message editor window and also the Preview button to see it's properly formatted).

[My Blog] [JavaRanch Journal]
Have you checked out Aspose?
subject: why my email validation is not working
It's not a secret anymore!