Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Enforcing email validation in javascript

  • 09-07-2012 11:13am
    #1
    Registered Users, Registered Users 2 Posts: 448 ✭✭


    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