[html5] r3516 - [e] (0) setCustomValidity() message.
whatwg at whatwg.org
whatwg at whatwg.org
Fri Jul 31 17:07:24 PDT 2009
Author: ianh
Date: 2009-07-31 17:07:22 -0700 (Fri, 31 Jul 2009)
New Revision: 3516
Modified:
index
source
Log:
[e] (0) setCustomValidity() message.
Modified: index
===================================================================
--- index 2009-07-31 23:00:26 UTC (rev 3515)
+++ index 2009-08-01 00:07:22 UTC (rev 3516)
@@ -71,7 +71,7 @@
<div class=head>
<p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<h1>HTML 5</h1>
- <h2 class="no-num no-toc" id=draft-standard-—-date:-01-jan-1901>Draft Standard — 31 July 2009</h2>
+ <h2 class="no-num no-toc" id=draft-standard-—-date:-01-jan-1901>Draft Standard — 1 August 2009</h2>
<p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -9406,27 +9406,29 @@
the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has
finished parsing</a>.</li>
- <li><p><a href=#pause>Pause</a> until <var title="">the script</var>
- has <a href=#completed-loading>completed loading</a>.</li>
+ <li><p><i>Loop</i>: If <var title="">the script</var> is a
+ <code><a href=#script>script</a></code> element without a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, then <a href=#executing-a-script-block title="executing a script block">execute</a> <var title="">the
+ script</var>.</li>
- <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> <var title="">the script</var>.</li>
+ <li><p>If <var title="">the script</var> is not the last script
+ in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document
+ has finished parsing</a>, then let <var title="">the
+ script</var> be the next script in that list, and return to the
+ step marked <i>loop</i>.</p>
- <li><p>Remove <var title="">the script</var> from the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list
- of scripts that will execute when the document has finished
- parsing</a> (i.e. shift out the first entry in the
- list).</li>
+ <li><p>Remove any scripts that were executed as part of this
+ algorithm from the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when
+ the document has finished parsing</a>.</li>
- <li><p>If there are any more entries in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts
- that will execute when the document has finished parsing</a>
- then jump back to step 1.</li>
-
</ol><!--
TESTS: http://www.hixie.ch/tests/adhoc/html/parsing/script-defer-write/
- Note: IE8 actually drops on the floor any scripts which in step 2
- of the algorithm above aren't yet completely loaded. I don't want
- to spec a race condition, though. The alternative to pausing like
- above, however, is to blow away the doc if the external scripts
- do document.write(), which apparently might cause issues.
+ Note: IE8 actually drops on the floor any scripts which had
+ src="" but aren't yet completely loaded, and executes the rest. I
+ don't want to spec a race condition, though, and other browser
+ vendors don't want to block on network I/O in
+ innerHTML. Unfortunately, this means that external scripts with
+ defer="" will blow away the document if they do document.write(),
+ which is incompatible with IE.
--></li>
<li>
@@ -36129,6 +36131,35 @@
<a href=#custom-validity-error-message>custom validity error message</a> to the value of the given
<var title="">message</var> argument.</p>
+ </div>
+
+ <div class=example>
+
+ <p>In the following example, a script checks the value of a form
+ control each time it is edited, and whenever it is not a valid
+ value, uses the <code title=dom-cva-setCustomValidity><a href=#dom-cva-setcustomvalidity>setCustomValidity()</a></code> method
+ to set an appropriate message.</p>
+
+ <pre><label>Feeling: <input name=f type="text" oninput="check(this)"></label>
+<script>
+ function check(input) {
+ if (input.value == "good" ||
+ input.value == "fine" ||
+ input.value == "tired") {
+ input.setCustomValidity('"' + input.value + '" is not a feeling.');
+<!-- } else if (input.value == "...") {
+ input.setCustomValidity('...');
+--> } else {
+ // input is fine -- reset the error message
+ input.setCustomValidity('');
+ }
+ }
+</script></pre>
+
+ </div>
+
+ <div class=impl>
+
<p>The <dfn id=dom-cva-validity title=dom-cva-validity><code>validity</code></dfn>
attribute must return a <code><a href=#validitystate>ValidityState</a></code> object that
represents the <a href=#validity-states>validity states</a> of the element. This
Modified: source
===================================================================
--- source 2009-07-31 23:00:26 UTC (rev 3515)
+++ source 2009-08-01 00:07:22 UTC (rev 3516)
@@ -9711,30 +9711,33 @@
the <span>list of scripts that will execute when the document has
finished parsing</span>.</p></li>
- <li><p><span>Pause</span> until <var title="">the script</var>
- has <span>completed loading</span>.</p></li>
+ <li><p><i>Loop</i>: If <var title="">the script</var> is a
+ <code>script</code> element without a <code
+ title="attr-script-src">src</code> attribute, then <span
+ title="executing a script block">execute</span> <var title="">the
+ script</var>.</p></li>
- <li><p><span title="executing a script block">Execute</span> <var
- title="">the script</var>.</p></li>
+ <li><p>If <var title="">the script</var> is not the last script
+ in the <span>list of scripts that will execute when the document
+ has finished parsing</span>, then let <var title="">the
+ script</var> be the next script in that list, and return to the
+ step marked <i>loop</i>.</p>
- <li><p>Remove <var title="">the script</var> from the <span>list
- of scripts that will execute when the document has finished
- parsing</span> (i.e. shift out the first entry in the
- list).</p></li>
+ <li><p>Remove any scripts that were executed as part of this
+ algorithm from the <span>list of scripts that will execute when
+ the document has finished parsing</span>.</p></li>
- <li><p>If there are any more entries in the <span>list of scripts
- that will execute when the document has finished parsing</span>
- then jump back to step 1.</p></li>
-
</ol>
<!--
TESTS: http://www.hixie.ch/tests/adhoc/html/parsing/script-defer-write/
- Note: IE8 actually drops on the floor any scripts which in step 2
- of the algorithm above aren't yet completely loaded. I don't want
- to spec a race condition, though. The alternative to pausing like
- above, however, is to blow away the doc if the external scripts
- do document.write(), which apparently might cause issues.
+ Note: IE8 actually drops on the floor any scripts which had
+ src="" but aren't yet completely loaded, and executes the rest. I
+ don't want to spec a race condition, though, and other browser
+ vendors don't want to block on network I/O in
+ innerHTML. Unfortunately, this means that external scripts with
+ defer="" will blow away the document if they do document.write(),
+ which is incompatible with IE.
-->
</li>
@@ -40488,6 +40491,36 @@
<span>custom validity error message</span> to the value of the given
<var title="">message</var> argument.</p>
+ </div>
+
+ <div class="example">
+
+ <p>In the following example, a script checks the value of a form
+ control each time it is edited, and whenever it is not a valid
+ value, uses the <code
+ title="dom-cva-setCustomValidity">setCustomValidity()</code> method
+ to set an appropriate message.</p>
+
+ <pre><label>Feeling: <input name=f type="text" oninput="check(this)"></label>
+<script>
+ function check(input) {
+ if (input.value == "good" ||
+ input.value == "fine" ||
+ input.value == "tired") {
+ input.setCustomValidity('"' + input.value + '" is not a feeling.');
+<!-- } else if (input.value == "...") {
+ input.setCustomValidity('...');
+--> } else {
+ // input is fine -- reset the error message
+ input.setCustomValidity('');
+ }
+ }
+</script></pre>
+
+ </div>
+
+ <div class="impl">
+
<p>The <dfn title="dom-cva-validity"><code>validity</code></dfn>
attribute must return a <code>ValidityState</code> object that
represents the <span>validity states</span> of the element. This
More information about the Commit-Watchers
mailing list