Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Help validating email address inputs

    Hi,

    I currently have a website that is specific to the academic / university area, and as such, I only want people with a .ac.uk email address to be able to register.

    I currently have a script in place to check that a valid email address is submitted in the correct format ie email@address.co.uk or .com etc etc.

    I am having trouble trying to create a validation check to make sure that ONLY email addresses ending in .ac.uk (email@address.ac.uk) are accepted ... everything else such as .co.uk .com etc would get declined.

    Any help would be greatly appreciated!

    Thanks

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,538
    Thanks
    45
    Thanked 259 Times in 256 Posts
    PHP Code:
     if (substr($email, -6) == '.ac.uk'// valid 
    Of course, you'll still want to validate the email as a whole, but that'll confirm the last 6 characters are '.ac.uk'.

  • Users who have thanked Keleth for this post:

    Cjc1706 (03-01-2012)

  • #3
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keleth View Post
    PHP Code:
     if (substr($email, -6) == '.ac.uk'// valid 
    Of course, you'll still want to validate the email as a whole, but that'll confirm the last 6 characters are '.ac.uk'.
    Perfect! That works a treat! Thank you very much!!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •