Restrict user to use a specific domain to sign up : django

前端 未结 2 667
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 08:14

I\'m a Django newbie.

I\'d like to restrict user to use a specific domain (e.g. @gmail.com ) to sign up my Django website, but how to customize the EmailField in my

2条回答
  •  盖世英雄少女心
    2021-01-01 08:55

    You can achieve the same via HTML5 input tag attribute (pattern). Say for example your domain is foo.com, then the code will be:

    
    

    Also you can change the error message by using the setCustomValidity of the DOM element.

    document.getElementById('email').setCustomValidity("Please use an @foo.com email address.");
    

提交回复
热议问题