Code Monkey home page Code Monkey logo

django-jquery-form-validation's People

Contributors

rafaponieman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

shabble madra

django-jquery-form-validation's Issues

Field names are wrong when a ChoiceField

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.

"regexp" is not a method

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.

http://stackoverflow.com/questions/280759/jquery-validate-how-to-add-a-rule-for-regular-expression-validation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.