Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Enforcing email validation in javascript

  • 09-07-2012 12:13PM
    #1
    Registered Users, Registered Users 2 Posts: 451 ✭✭


    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:user@url.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>


Comments

  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    you could have a div around the comments and once the email address is valid make the div visible.

    You could use some jquery and so some fancy checking.

    btw having an "@" does not make the email address valid. All it means is that
    1: at least part of the mail address is valid
    2: even if I enter a fully valid email address (properly formed) t@t.com doesn't mean the email address exists so you still can't contact the person
    3: even if I enter t@t.com and the email exists there is no proof that I am the owner of the email address.

    The above is why people have to register to use a site/make comments as it allows you to validate their email.


Advertisement