HTML5 novalidate only for some inputs

htmlvalidation

I've got really simple question – is there any way to disable HTML5 validation only for some chosen inputs (instead of setting "novalidate" for whole form)?

I mean something like <input type='number' requirednovalidate>. But this doesn't work.

You may ask why I need type="number" or "required" then? Well, I need it there because my framework uses it for its own validation.

EDIT

It is about one special input – birth number. I need it to be of type number (because of mobile devices) but its value is mostly used with "/" (e.g. 860518/8757) which is not valid character for type number. So I need user to fill it without slash (8605188757). The problem is when there is invalid value filled in html5 input (e.g. "fsda" in number type), it seems like it is empty, with no value.

So when user fill the value in wrong format (860518/8757), html validation is disabled so the JS validation runs, it is validated like empty field. So the error message is like "Please fill the field birth number" (which is really confusing) instead somthing like "Sorry, wrong format".

My solution was to enable html5 validation for this field (so the default browser message is displayed when there is wrong format filled) but disable it for other fields so that they would be validated only with my JS validation.

Best Answer

You cannot disable HTML5 validation for a chosen input(s).

If you want to remove validation on the entire form you can use formnovalidate in your input element.

For example,

<input type="submit" value="Save" class="button primary large" formnovalidate/>

Note you can use formnovalidate with <input type=submit>, <inut type=image> or <button> -source

For more info go here or here.