W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2007

[whatwg] WF2: Non-validating submit buttons

From: Christian Schmidt <whatwg.org@chsc.dk>
Date: Wed, 21 Mar 2007 17:23:21 +0100
Message-ID: <46015BF9.2090208@chsc.dk>
Martin Atkins skrev:
> It would be useful to be able to mark certain submit buttons as 
> non-validating.
> 
> [...]
> 
>     <input type="submit" validate="no" />
> 
> I'm not fussed about the exact name/usage of the attribute, but it seems 
> like a common enough case to warrant a declarative solution rather than 
> a script one.

How would this be achieved using script?


One way is to use a button with the following onclick handler:

for (var i = 0; i < form.elements.length; i++) {
     var element = form.elements[i];
     if (!element.validity.valid) {
         element.type = 'text';
         element.required = false;
         element.maxLength = -1;
         element.setCustomValidity(null);
     }
}
form.submit();

Is there a more elegant solution?


Christian
Received on Wednesday, 21 March 2007 09:23:21 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:53 UTC