bootstrap-validator icon indicating copy to clipboard operation
bootstrap-validator copied to clipboard

Hidden fields

Open checklist opened this issue 8 years ago • 5 comments

Hi,

I have a form which includes a modal/ajax upload of a file, the result of which is to update a field with a mediaId. I need to make sure the user has uploaded an image so I added required to the hidden field as follows:

<div class="form-group">
    <input id="mediaId" name="mediaId" required="true" type="hidden" value=""/>
    <div class="help-block with-errors"></div>
</div>

But unfortunately, no error message is shown and the user can submit the form. How to tack?

checklist avatar May 11 '16 08:05 checklist

I have a similar issue and it looks like it's not working at all inside a modal window. It does work with onblur() but submit event is not prevented

hugomiggels avatar May 16 '16 12:05 hugomiggels

+1

EralpB avatar Sep 07 '16 16:09 EralpB

+1, this is also the browser behavior: https://jsfiddle.net/kwtzktn3/ If you send the form, it doesn't give you any validation warnings in chrome.

Langmans avatar Jul 05 '17 07:07 Langmans

You need to change the INPUT_SELECTOR the plugin uses to determine what types of fields to check. By default, it excludes [type="hidden"] fields.

$.fn.validator.Constructor.INPUT_SELECTOR = ':input:not([type="submit"], [type="reset"], button)'

1000hz avatar Jul 10 '17 19:07 1000hz

According to the documentation, adding data-validate="true" should also work. But it doesn't. See #333

SimJoSt avatar Feb 26 '18 16:02 SimJoSt