3

I saw a version of JQuery EDU validation here but I'd love to use django-registraion to check a full domain @someschool.edu or @alumni.someschool.edu

Any ideas? Thanks for your help.

Community
  • 1
  • 1
jmitchel3
  • 391
  • 3
  • 4
  • 17
  • Not sure of how to validate domain, but you can verify emails: http://stackoverflow.com/questions/565504/how-to-check-if-an-email-address-exists-without-sending-an-email?rq=1 – karthikr Jan 06 '13 at 06:17

1 Answers1

4

You can create your own form in forms.py, you already have some example for :

  • registration with term of service
  • registration with unique mail
  • registration without freeemail

In your case add :

class RegistrationFormEduMail(RegistrationForm):

    good_domains = ['edu']

    def clean_email(self):

        email_domain = self.cleaned_data['email'].split('.')[-1]
        if email_domain not in self.good_domains:
            raise forms.ValidationError(_("Registration using non edu email addresses is prohibited. Please supply a different email address."))
        return self.cleaned_data['email']

Then go in registration/backends/default/init.py and import your form, change the name of the form returned by get_form_class() method to the name of your form (here: RegistrationFormEduMail)

ltbesh
  • 667
  • 1
  • 10
  • 24