In this article we will learn about some of the frequently asked HTML programming questions in technical like “sample html form to render” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on html was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in HTML. Below are some solution about “sample html form to render” Code Answer.
sample html form to render
xxxxxxxxxx
1
from django import forms
2
3
class ContactForm(forms.Form):
4
name = forms.CharField(max_length=30)
5
email = forms.EmailField(max_length=254)
6
message = forms.CharField(
7
max_length=2000,
8
widget=forms.Textarea(),
9
help_text='Write here your message!'
10
)
11
source = forms.CharField( # A hidden input for internal use
12
max_length=50, # tell from which page the user sent the message
13
widget=forms.HiddenInput()
14
)
15
16
def clean(self):
17
cleaned_data = super(ContactForm, self).clean()
18
name = cleaned_data.get('name')
19
email = cleaned_data.get('email')
20
message = cleaned_data.get('message')
21
if not name and not email and not message:
22
raise forms.ValidationError('You have to write something!')