While using Django modelforms I have a Integer field which is numeric only. But in the browser it comes as a text field in which I can enter "characters". I want to make this only "numeric". How to do this ? i.e. users should be able to enter only numbers.
We can do it 1 way by setting the attribute of the field.
1)
def __init__(self,*args,**kwargs):
super(PropertyForm,self).__init__(*args, **kwargs)
self.fields['brokers_phone_number'].widget.attrs['type'] = "number"
This does not seem to work. I am using html 5 and the browser is Chrome. What am I doing wrong ? How can It be done better ?