surreal5335
New Member
- Messages
- 28
- Reaction score
- 0
- Points
- 0
I have email form created with the javascript validation already coded. When I click on the submit button no alert boxes pop to warn me I dont have the fields entered. Can anybody help me to get the JS to take action when the submit button is clicked?
here is the page of code including the JS and email form:
Thanks a lot for your help
here is the page of code including the JS and email form:
Code:
[B]<html>[/B]
[B]<head>[/B]
[B][B]<script type="text/javascript" language="JavaScript">[/B][/B]
//validating email address
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
[I]function[/I] submitit(myform) {
[I]if[/I] (re.test(myform.emailaddr.value)) {
[I]return[/I] [I]true[/I]
}
[I]alert[/I]("invalid email address")
myform.emailaddr.focus( )
myform.emailaddr.select( )
[I]return[/I] [I]false[/I]
}
[I]function[/I] validform(emailaddrform) {
[I]if[/I] (emailaddrform.emailaddr1.value == "") {
[I]alert[/I]("You must enter an email address")
emailaddrform.emailaddr1.focus( )
[I]return[/I] [I]false[/I]
}
[I]if[/I] (emailform.emailaddr1.value ! = emailform.emailaddr2.value) {
[I]alert[/I]("Entered email addresses did not match")
emailform.emailaddr1.focus( )
emailform.emailaddr1.select( )
[I]return[/I] [I]false[/I]
}
[I]return[/I] [I]true[/I]
}
[B][B]</script>[/B][/B]
[B]</head>[/B]
[B]<body>[/B]
[B]<table border="1" width="100%">[/B]
[B]<tr>[/B]
[B]<td width="10%">[/B]
[B]<map name="homeleft" id="homeleft" align="left">[/B]
[B]<area shape="rect" coords="10, 10, 212, 219" href="index.html"/>[/B]
[B]<area shape="rect" coords="66, 253, 168, 303" href="realestatepost.html"/>[/B]
[B]<area shape="rect" coords="66, 342, 168, 391" href="graphics.html"/>[/B]
[B]</map>[/B]
[B]<img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/homeleft.png" usemap="#homeleft" id="homeleft" hspace="10" vspace="10" align="center">[/B][B]<br>[/B]
[B]</td>[/B]
[B]<td width="80%">[/B]
<!--home content--!>
[B]<img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/portfolioheader.png" hspace="10" vspace="10" align="center">[/B][B]<br/>[/B][B]<br>[/B]
[B][U]<form method="post" name="emailform" action="emailform.php">[/U][/B]
[B]<p class="legend">[/B]Contact via email[B]</p>[/B]
[B]<fieldset id="conact">[/B]
[B][U]<[I]label[/I]>[/U][/B]Name: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="name" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Email: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="emailaddr1" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Email: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="emailaddr2" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Phone: [B][U]</[I]label[/I]>[/U][/B][B][U]<input type="text" name="phone" size="30"/>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<[I]label[/I]>[/U][/B]Comments: [B][U]</[I]label[/I]>[/U][/B][B]<br>[/B][B][U]<textarea name="comments" rows="10" cols="30">[/U][/B]Please give me a brief description of the work you need done[B][U]</textarea>[/U][/B][B]<br/>[/B]
[B]<br>[/B]
[B][U]<input type="submit" name="submit">[/U][/B][B]<a href="thankyou.html">[/B][B]</a>[/B][B][U]</button>[/U][/B][B]<br/>[/B]
[B]</td>[/B]
[B]<td width="10%">[/B]
[B]<map name="homeright" id="homeright" align="left">[/B]
[B]<area shape="rect" coords="37, 530, 191, 683" href="contact.html"/>[/B]
[B]</map>[/B]
[B]<img src="http://i95.photobucket.com/albums/l136/surreal5335/web%20builder/homeright.png" usemap="#homeright" id="homeright" hspace="10" vspace="10" align="center">[/B][B]<br>[/B]
[B]</td>[/B]
[B]</tr>[/B]
[B]</body>[/B]
[B]</table>[/B]
[B]</html>[/B]
Thanks a lot for your help