Register now or log in to join your professional community.
I use Djando :
class SignUpFormss (forms.ModelForm): class Meta: model = SignUp fields=['email','fullname']def clean_email(self): email=self.cleaned_data.get('email')if not "gmail" in email: raise forms.ValidationError("please enter gmail.com")return email
use a client side validation like (jquery) or you can just use ajax request
ajax is the best option. most of the web sites are using this.
Use Ajax to poll the data and trigger the popup if the data is valid.
Using ajax with Django is as simple as any other platform, but only one thing to keep in mind is setting the XHR for csrf (in case of posting data).
$.ajax({
type: "POST",
data: "uid={{id}}",
url: "your app url",
beforeSend: function(xhr, settings){
xhr.setRequestHeader('X-CSRFToken','{{ csrf_token }}');
},
success: function(data) {
alert(data);
}
});