Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enforcing e-mail validation 1

Status
Not open for further replies.

gibsonguy

Technical User
Jul 9, 2012
2
0
0
Hi everyone (first post here)
I'm looking for a way to force the user to validate their email address and when this works give them access to send in user comments /questions etc. I have the two separate pieces of code both working but need a way to join them. Just to clarify, the user comment section should remain non-accessible until the user has run the email validation part.

Appreciate all replies!

Email Validation Code
-----------
*/
function evalform(address)
{ crucial = address.indexOf ("@");
if(crucial == -1)
{ window.alert("The E-mail address you entered is not a valid E-mail address.");
return false }
else
{ message = "You entered "+address+" -- Is this correct?";
return window.confirm(message)};
}


</SCRIPT>
</HEAD>
<BODY>
<FORM onSubmit="evalform(this.email.value)">
E-mail:
<INPUT NAME="email" TYPE="text" ROWS=1 SIZE="20">
<INPUT NAME="Submit" TYPE="Submit">
<INPUT NAME="Reset" TYPE="Reset">



Question/Comment Code
----------------------------

<h1><font color="white">Thanks for visiting our website</font></h1>
<h2><font color="white">Please fill in the attached form to register with us or to simply send any questions or comments</h2>

<SCRIPT LANGUAGE="javascript">
function verify()
{
var OpenWindow=window.open("", "newwin", "height=300,width=300");
OpenWindow.document.write("<HTML>")
OpenWindow.document.write("<TITLE>Thanks for Writing</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR='ffffcc'>")
OpenWindow.document.write("<CENTER>")
OpenWindow.document.write("Thank you <B>" + name + "</B> from <B>" +email+ "</B><P>")
OpenWindow.document.write("Your message <P><I>" + document.gbookForm.maintext.value + "</I><P>")
OpenWindow.document.write("from " + name + " / " +email+ "<P>")
OpenWindow.document.write("will be sent along when you close this window.<p>")
OpenWindow.document.write("<CENTER>")
OpenWindow.document.write("<FORM><INPUT TYPE='button' VALUE='Close Window' onClick='self.close()'></FORM>")
OpenWindow.document.write("</CENTER>")
OpenWindow.document.write("</HTML>")

}
</script>

<SCRIPT LANGUAGE='javascript'>


document.write("<FORM METHOD='post' ACTION='mailto:jburns@htmlgoodies.com?Subject=Mail from " +name+ " at " +email+ "' ENCTYPE='text/plain' NAME='gbookForm'>")

</SCRIPT>

<b>What would you like to tell me?<BR></b>
<TEXTAREA COLS="40" ROWS="20" NAME="maintext"></TEXTAREA><P>
<INPUT TYPE="submit" VALUE="Send It" onClick="verify()">
</FORM>
 
Hi

1) First of all, you must [tt]return[/tt] from the event handler too :
JavaScript:
[teal]<[/teal]FORM onSubmit[teal]=[/teal][green][i]"[highlight]return[/highlight] evalform(this.email.value)"[/i][/green][teal]>[/teal]

2) Then your validation is a poor joke. It will accept invalid addresses like @, @@@, gibsonguy!?@. And anyway, you can not check for nonexistent (?) addresses, like [ignore]gibsonguy@whitehouse.gov[/ignore]. Personally I would just remove all that "validation".

3)
gibsonguy said:
document.write("<FORM METHOD='post' ACTION='mailto:jburns@htmlgoodies.com?Subject=Mail from " +name+ " at " +email+ "' ENCTYPE='text/plain' NAME='gbookForm'>")
Why are you asking about the visitor's mail address if comments will be sent through email ? You will get the sender address there anyway.

4) No idea what should be the relation between the two [tt]form[/tt]s. Post some explanation on this.

Next time please post your code between [tt][ignore]
Code:
[/ignore][/tt] and [tt][ignore]
[/ignore][/tt] TGML tags.

Feherke.
[link feherke.github.com/][/url]
 
for form validation buddy, use common rules such as

you must have text preceding the '@'

and

you must have a valid top level domain after the domain name itself i.e

JSmith@johnsmith.com (where .com is your TLD)

perhaps create an xml file , and use simpleXML to do a substr function and compare the .domain part with all the .domains in the xml file. NAh, just use a comma delimitted text file better this way.

i.e com,co.uk,net,biz,ac.uk,etc etc

its entirely up to you what ones u allow and dont and how fine tuned u want the validation to be for checking correct format entry of email address in form.

so after ALL These little rules are checked and validated, only THEN will your form process and submit that emai laddress.

not quite sure what you were trying to do there with the @ thing though.

you can't test for existence of email addresses in the domain space out there, thats ICANNs job buddy lol

also, what you CAN do is - you can for arguments sakes keep a basic RULE - that is, something must be infront of '@' and something after it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top