CaffGeek
CaffGeek

Reputation: 22064

html5 form validation (without submitting)

I have a modal div that appears in my app, it contains form elements, but I don't want to submit the form, the values get written into other DOM elements on the page.

I do however, want to ensure the fields in this modal are valid before allowing the 'Ok' action to execute.

I need this to work in IE9 (which IIRC does not support .checkValidity())

So, what I'm asking is, when I click an Ok button (not a submit button) how can I validate and show what's invalid on this form, without submitting.

I would prefer to use as much html5 functionality (<input required /> and such) as possible.

JsFiddle: http://jsfiddle.net/gibble/AtHas/

Upvotes: 3

Views: 10920

Answers (2)

Kevin
Kevin

Reputation: 532

JQuery has a plugin for validation that can be made to handle what you are trying to accomplish.

http://docs.jquery.com/Plugins/Validation

Upvotes: 2

nycynik
nycynik

Reputation: 7541

Here is a link to a similar question:

What javascript fallback does best simulate html5 form validation

Form validation in html5 does not work in all browsers, we just have to wait, and implement javascript in the meantime.

Upvotes: 0

Related Questions