The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rails validates_format_of :email - Email Address Regular Expression - And PHP too

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Nathaniel Brown

Posts: 54
Nickname: nshb
Registered: Oct, 2005

Nathaniel Brown is Technology Consultant in Vancouver, Canada
Rails validates_format_of :email - Email Address Regular Expression - And PHP too Posted: Jul 30, 2007 12:45 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Nathaniel Brown.
Original Post: Rails validates_format_of :email - Email Address Regular Expression - And PHP too
Feed Title: Nathaniel Brown
Feed URL: http://feeds.feedburner.com/nshb
Feed Description: Insight as a professional Technology Consltant and Photographer.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Nathaniel Brown
Latest Posts From Nathaniel Brown

Advertisement

This simple code validates an email address to ensure that it complies with standard formatting.

You can put this in your model like so:


class Person < ActiveRecord::Base
validates_format_of :email, :with => /^\S+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/ix
end

If you have PHP code - try this..


$valid_email = preg_match('/^\S+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/', $email);

Read: Rails validates_format_of :email - Email Address Regular Expression - And PHP too

Topic: Matz Linked to Me Previous Topic   Next Topic Topic: YSlow and Rails performance: Getting UJS and AssetPackager to play nice

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use