cferdinandi / validate

A lightweight form validation script.
MIT License
230 stars 39 forks source link

Change to default errors IDs so that square brackets are subbed for hyphens #44

Closed dansiberry closed 1 year ago

dansiberry commented 6 years ago

A small suggestion about subbing square brackets for hyphens when the error IDs are copied directly from the field name .

In my use case in Rails, fields with names such as 'user[profile_attributes][username]' were producing default IDs that weren't searchable with querySelector. A value of null is returned instead of the DOM node. Eg - document.querySelecter('.form-error-message#error-for-user[email]') -> null

This means the errors stack up as the function to remove them isn't finding the element.

I was unable to run the Gulp build unfortunately. Please advise on version number changes