Mevrael / bunny

BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.
https://bunnyjs.com
MIT License
487 stars 39 forks source link

problem to remove a required field #27

Open francosalcedo opened 6 years ago

francosalcedo commented 6 years ago

Reproduce problem: https://jsfiddle.net/oc0veLLp/9/

Hi, I have the following problem, if I want a field to don't required (Once the form has been initialized, and this changed dynamically), I delete the "required" by javascript but if the field has other attributes such as "minLength" or "maxLength" it is still mandatory.

How can I solve this in the best way?

thanks

Mevrael commented 6 years ago

Thank you for bug report.

As I see per code, minLength and maxLength validators do not check if input is empty.

I will update code in coming days. For now you can manually remove also min/max attributes.

francosalcedo commented 6 years ago

@Mevrael
Thank you for your prompt response, I will be attentive.

Mevrael commented 6 years ago

Hi @francosalcedo

I am very sorry for delay and I do believe you solved you problem by adjusting code manually, however, I would appreciate if you could do a simple PR and just add input.value.length > 0 to min/max length validators.

https://github.com/Mevrael/bunny/blob/master/src/Validation.js#L157

You can scroll this line up and check "tel" validator to see an example.

I will get my IDE and anything else on my machine this weekend and would be able just to merge, build and release new NPM version.

Thanks