Re: [whatwg] [WF2] select required
Well, the option element could be extended with a new attribute 'invalid' which hold prevent that option to be selected. Robert [EMAIL PROTECTED] escreveu: On Mon, 02 Oct 2006 16:35:32 +0200, Simon Pieters [EMAIL PROTECTED] wrote: I've seen a case where a select is used and the user is required to change its value, as in: select name=test required option value=Select one: optionFoo optionBar /select Now this can be done with radio buttons instead, but why can't the above be supported? That is, make required apply to selects and if the value is empty then required is not satisfied. (Same for select multiple.) Submitting an empty value may be wanted, and since a select by definition is a list of predefined valid values, it would make little sense to prevent the user from selecting some of them. However, I agree with the use case of the invalid starter value so users must consciously select a value they wanted instead of the default one. The following script will do exactly what you wanted, although Opera doesn't seem to use the custom error message for some reason. I'm not sure if that's my fault or Opera's due to my lack of experience with WF2, but it does prevent form submissions just fine as long as there are invalid selects. The script works in Opera 9.02. script type=text/javascript![CDATA[ function checkSelect(e){ var test = e.target; if(e.target.value == '') e.target.setCustomValidity('You must select a value.'); else e.target.setCustomValidity(null); } // Use '//select' for html documents, or use a wrapper function // that strips namespace prefixes for plain 'ol html. var res = document.evaluate('//html:select',document, function(pfx){return 'http://www.w3.org/1999/xhtml';},4,null); var elem=null; while(elem = res.iterateNext()){ if(!elem)break; checkSelect({'target':elem}); // do initial check elem.addEventListener('change',checkSelect,false); } ]]/script -- Robert Græsdal
Re: [whatwg] [WF2] select required
On Wed, 04 Oct 2006 02:32:27 +0200, Simon Pieters [EMAIL PROTECTED] wrote: Then don't mark the select as being required. Or do you mean that there are cases where the user has to change the value to ? What would that be? One case could be that an old web application is configured serverside to interpret an empty value as none of the above. For the author, it would be risky to change this as opposed to just slapping on some added functionality for modern browsers on the client side. So should there be a declarative way to express this? I say yes, but I think pattern is a better candidate than required, or as Joao Eiras suggested, marking certain options as invalid - or all of the above. - Robert Græsdal
Re: [whatwg] [WebForms2] custom form validation notifications without scripting
On 10/3/06, Joao Eiras [EMAIL PROTECTED] wrote: Although WebForm2 provides automatic validation of form content from the UA side, the specification has a few gaps related to customizablility of notifications, by web authors, without scripting enabled. If the user fills a form in an improper way the UA should alert him of the problems. Opera in the early days of its initial web forms support showed an alert box stating that the information was invalid, now it flashes the input field, and presents a message overlapped in the webpage. However it presents a very generic error message like You must set a value! (for required) or foo is not in the format this page requires (for pattern). The author may want, in the case of an error, to present its custom error message to the end user. This could be achieved by declaring new custom attribute for the several controls, which could hold the message. The UA could then either pop up that message to the user or embed it in the page (like Opera does currently). The attribute could be named like requirederr, patternerr, or use some other sort of naming convention to easily associate the constraining property with the message attribute. Is the use of the title attribute inappropriate for this case? -- Brad Fults
Re: [whatwg] [WebForms2] custom form validation notifications without scripting
Na , Brad Fults [EMAIL PROTECTED] escreveu: On 10/3/06, Joao Eiras [EMAIL PROTECTED] wrote: Although WebForm2 provides automatic validation of form content from the UA side, the specification has a few gaps related to customizablility of notifications, by web authors, without scripting enabled. If the user fills a form in an improper way the UA should alert him of the problems. Opera in the early days of its initial web forms support showed an alert box stating that the information was invalid, now it flashes the input field, and presents a message overlapped in the webpage. However it presents a very generic error message like You must set a value! (for required) or foo is not in the format this page requires (for pattern). The author may want, in the case of an error, to present its custom error message to the end user. This could be achieved by declaring new custom attribute for the several controls, which could hold the message. The UA could then either pop up that message to the user or embed it in the page (like Opera does currently). The attribute could be named like requirederr, patternerr, or use some other sort of naming convention to easily associate the constraining property with the message attribute. Is the use of the title attribute inappropriate for this case? I believe title is used for a berief description, not for error messages, besides a control may not validate for more than one reason.