rafaponieman / django-jquery-form-validation Goto Github PK
View Code? Open in Web Editor NEWJquery Form Validation for Django
Jquery Form Validation for Django
I don't know if this project is still being maintained, but I don't think forms.ChoiceField
gets the correct name.
The current code checks against a few different types, but not forms.ChoiceField
. As it stands, Django makes those HTML widgets like <input type="radio" id="id_[model_field]-[form_field]_1" value="True" name="[model_field]-[form_field]" required="required">
.
The template tag currently interprets the choice field with just a name, so {% validation_rules form %}
ends up looking like {"[form_field]": {"required": true}}
which doesn't correspond to the HTML widgets that Django makes. It would need to be {"[model_field]-[form_field]": {"required": true}}
My guess would be to add another check like if(isinstance(form.fields[field_name], forms.ChoiceField)):
but I wouldn't know where to go from there.
Maybe one more issue.
Django has its own regexes for websites, zip codes, and probably others. Those rules are passed with key "regexp" and value regex string. According to the plugin, "regex" is not a valid rule to check against, like required
, minlength
, maxlength
, etc. The JS errors out, and the form goes forward with a full page refresh and relies on Django for server-side validation.
Adding custom regex rules to jQuery Validation seems to be the way to go, but doesn't appear trivial.
There might be a way to infer which field is a website/URL, email, etc., and then use jQuery Validation's own internal regex, because it ships with its own, but that might be difficult or impossible to infer.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.