[whatwg] WF2: Non-validating submit buttons

Christian Schmidt whatwg.org at chsc.dk
Wed Mar 21 09:23:21 PDT 2007


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



More information about the whatwg mailing list