Custom additional email field in Checkout Form

mwinsteinmwinstein Member
in Help edited July 2008
I would like to add an additional email field in the custom field section on my Checkout Form, and would like to have the that field for validated like you do it for the main email.

I understand how to add a custom field, but I don't know how to do the email validation.

Can you advise?
Comments
  • lukeluke FoxyCart Team
    You'll need an email validation function, much like this, and then bind it to the custom field:
    function isValidEmail(email) {
    	var emailNotOk = !email.match(/^[A-Z0-9._%\-+]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i);
    	return !emailNotOk;
    }
    
    Then use some JQuery to add some onblur to your custom field, like so:
    $j("#my_custom_email").blur(function() {
    if (!isValidEmail(this.value)) {
      // display your error div here or alert message
    }
    });
    
    I haven't tested any of that... but it should give you a start for what you need. Defining the blur binding would be done inside a document onload.
  • mwinsteinmwinstein Member
    edited July 2008
    This makes sense. But can I get this java functionality from an existing class for a text field?
  • brettbrett FoxyCart Team
    Our next version will allow much greater re-usability of the existing FoxyCart javascript, but as is now it's not quite so easy to use the existing code. That's only a half-answer, I know, but we're moving in that direction.
  • mwinsteinmwinstein Member
    edited July 2008
    Hi Brett,

    No problem. I've been fiddling with my checkout - you can see the result starting from my one-button order form.

    Using this strategy, I will ask people to enter a separate email address to which they want their subscription sent. (one question here, the <h4> label doesn't seem to show up in the blank space above the line of this div...)

    But I think the real solution to what I'm getting at here is to allow the CartMaster like me to elect to set the cart to accept a made-up USERNAME from the shopper instead of requiring the person to enter their email address as their username in the login credentials, and instead have the email as a required field under "your billing address" (I"d retitle that "your billing information").

    That way, changing an email addresses wouldn't be such a big deal. That's how Godaddy does their thing, and as a long term customer I have made use of their granted ability to change my Username, password, and my email. I am looking to build long-term subscription relations, like GoDaddy, and I think if you give at least the option to ask for a Username instead of email, it will solve a whole range of solutions that people want to create via all the other cool integration features you offer.
  • Uh oh --

    I tested that form with a new email and completed the order. Then, I went back using the Update function - where someone can update their subscription info - and the 2nd email didn't pull up from the dataset. Now what?....
  • mwinsteinmwinstein Member
    edited July 2008
    Look, I don't want to wear you guys out. I can work around this by allowing people to fix their email address via MailChimp and fixing their billing info via FoxyCart, but it would be cooler if my customers could do it all in one place....
  • lukeluke FoxyCart Team
    In the future, we will allow customers to change their email address, provided the new email isn't already in the system for that store. I don't think we'll move towards a "username" field, however, as every system I've ever used that has both becomes frustrating. Both usernames and emails need to be unqiue per user, so there's a lot of redundancy there. Also, by using the email address as the login (and giving the user the ability to change it), you remind your user to keep their information up-to-date. Most online systems heavily rely on the email address being accurate to communicate with their customers. If someone logs in using an old email address, they will be much more likely to change it as opposed to if they just have a username and don't remember what email address is associated with it.

    Thanks for your feedback, we definitely appreciate it. User feedback is what has helped us get this far and will help us get where we're going in the future as well.
  • I like your answer, and look forward to hearing when the email is editable. I might even consider changing my own portal system which uses both unique userid and unique email
Sign In or Register to comment.