snarfed.org

Ryan Barrett's blog

snipsnap register without email

Wed, 01 Jan 2003 [comments (1)] [history] [rdf] [raw]

snipsnap-logo.png

This article is also posted on snipsnap.org.

I don't want your email address...

SnipSnap, which powers this site, lets visitors register so that they can log in, comment on existing pages, and create their own pages. The default registration page asks you for a username, a a password, and optionally, an email address. It's not obvious that the email is optional, though, and many people have learned not to give their email address to random web sites.

My site is small and personal, so I don't need email addresses. On the contrary, I don't want anything to discourage my friends from registering. So, I decided to remove the email box on the registration page altogether.

...so don't give it to me!

I could do this by editing the JSP files, but that was a little too invasive for my tastes. (I really should do this eventually, though...anyone want to post a tutorial on editing the SnipSnap JSPs?) Instead, I used CSS, and simply added this to misc.css in my SnipSnap theme:

/* don't ask people for their email address */
input#email { display: none; }


The CSS only explicitly targets the input field, but it hides both the input field and the label. I believe that's because the label's for attribute points to the input field, like so:

<label for="email">Email address:</label>


In any case, it works, so I won't argue!

In the old days, we walked, uphill, both ways!

Earlier versions of SnipSnap didn't provide an id for the email input. So, I originally did this with Javascript, DOM, and CSS. Here's how. Save this as noemail.js in your application's directory:

/* Hide the email address input box on
    /exec/register.jsp .
 */

emailbox = document.getElementById('email');
if (emailbox) {
  emailbox.style.display = 'none';
}

label = document.getElementsByTagName('label')[1];
if (label &&
    label.innerHTML == 'Email address:') {
  label.style.display = 'none';
}


Then, add a link to noemail.js:

<script type="text/javascript" src="/snarfed.js" />


Again, you could edit the JSPs to put this in the section, but I'm intent on avoiding the JSPs, so I just wrote a macro to insert this tag.

Hope this helps!

See also:

comment bubble OpenID bob (not my real name), Tue 10 Nov 2009

so am i supposed to copy & paste to my clip board or what?
sorry if this comment is not good because i hust skimmed over the article.

PS copy and paste the msg below to anywhere

copy and paste

Post a comment...



Simple HTML and wiki markup are allowed.