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.

Home Page:https://bunnyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to reset validation?

VicoErv opened this issue · comments

Hi @VicoErv

I believe you are well.

Thank you for your question. Could you please tell me a bit more about a use case and how exactly it should work in your opinion?

Hello @Mevrael
In my case, i have form in modal dialog for add / edit user data, when i input that violated validation it show error. and then i want to clear the error after modal dialog is hidden. my temporary solution is remove error element that generated by this library manually

Hi @VicoErv

I believe you had a great weekend and sorry for delay.

Well, if you just want to remove error messages, you can Validation.ui.removeErrorNodesFromSection(HTMLElement node)

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

(P.S. at some point I plan to rename Validation.ui to Validation.UI, so probably at that point it would be better for you to import and use ValidationUI object itself.)

However, in that case I suppose you also would need to clear all inputs you have in this modal, otherwise, input might be filled with wrong value, but you would just remove error message and leave user alone with small UX question.

Usually, you also keep state of the modal forms as they were in case user would accidentally close it or just would like to continue a bit later. It's nice to see that you didn't lose your work.

Please let me know if would have any further comments or questions.