month.html (5312B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Inputs Month</title> 5 <link rel="author" title="Morishita Hiromitsu" href="mailto:hero@asterisk-works.jp"> 6 <link rel="author" title="kaseijin" href="mailto:pcmkas@gmail.com"> 7 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> 8 <link rel="help" href="https://html.spec.whatwg.org/multipage/#months"> 9 <link rel="help" href="https://html.spec.whatwg.org/multipage/#month-state-(type=month)"> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 </head> 13 <body> 14 <h1>Inputs Month</h1> 15 <div style="display: none"> 16 <input id="valid_value_1" type="month" value="20133-12" /> 17 <input id="valid_value_2" type="month" value="2013-12" /> 18 <input id="valid_value_3" type="month" value="0003-01" /> 19 <input id="valid" type="month" value="2011-11" min="2011-01" max="2011-12" /> 20 <input id="invalid_value" type="month" value="invalid-month" min="2011-01" max="2011-12"/> 21 <input id="value_can_be_empty_string" type="month" value="2013-06" /> 22 <input id="invalid_value_with_two_digits_year" type="month" value="13-06" /> 23 <input id="invalid_value_is_set" type="month" /> 24 <input id="step_attribute_is_invalid_value" type="month" value="2013-06" step="invalid_step_value" /> 25 <input id="invalid_month_too_high" type="month" value="2013-13" /> 26 <input id="invalid_month_too_low" type="month" value="2013-00" /> 27 <input id="invalid_year_all_zero" type="month" value="0000-10" /> 28 <input id="invalid_month_with_one_number" type="month" value="2013-1" /> 29 <input id="invalid_month_non_numerical" type="month" value="2013-abc" /> 30 <input id="invalid_date_additional_tuples" type="month" value="2013-11-1-1" /> 31 </div> 32 33 <div id="log"></div> 34 35 <script> 36 test(function() { 37 assert_equals(document.getElementById("valid_value_1").value, "20133-12") 38 }, "year can be more than four digits"); 39 40 test(function() { 41 assert_equals(document.getElementById("valid_value_2").value, "2013-12") 42 }, "valid value test"); 43 44 test(function() { 45 assert_equals(document.getElementById("valid_value_3").value, "0003-01") 46 }, "year can contain prefixes of zero, as long as there are at least four digits"); 47 48 test(function() { 49 assert_equals(document.getElementById("valid").type, "month") 50 }, "month type support on input element"); 51 52 test(function() { 53 assert_equals(document.getElementById("invalid_value").value, "") 54 }, "User agents must not allow the user to set the value to a non-empty string that is not a valid month string."); 55 56 test(function() { 57 document.getElementById("value_can_be_empty_string").value = ""; 58 assert_equals(document.getElementById("value_can_be_empty_string").value, "") 59 }, "Month value can be empty string."); 60 61 test(function() { 62 assert_equals(document.getElementById("invalid_value_with_two_digits_year").value, "") 63 }, "When value attribute has two digits year value, the value,which is invalid, must return empty string."); 64 65 test(function() { 66 document.getElementById("invalid_value_is_set").value = "invalid value"; 67 assert_equals(document.getElementById("invalid_value_is_set").value, "") 68 }, "When value is set with invalid value, the value must return empty string."); 69 70 test(function() { 71 document.getElementById("step_attribute_is_invalid_value").stepUp(); 72 assert_equals(document.getElementById("step_attribute_is_invalid_value").value, "2013-07") 73 }, "When step attribute is given invalid value, it must ignore the invalid value and use defaul value instead."); 74 75 test(function() { 76 assert_equals(document.getElementById("invalid_month_too_high").value, ""); 77 }, "Month should be <= 13: If the value of the element is not a valid month string, then set it to the empty string instead."); 78 79 test(function() { 80 assert_equals(document.getElementById("invalid_month_too_low").value, ""); 81 }, "Month should be > 0: If the value of the element is not a valid month string, then set it to the empty string instead.>"); 82 83 test(function() { 84 assert_equals(document.getElementById("invalid_year_all_zero").value, ""); 85 }, "Year should be > 0: If the value of the element is not a valid year string, then set it to the empty string instead.>"); 86 87 test(function() { 88 assert_equals(document.getElementById("invalid_month_with_one_number").value, ""); 89 }, "Month should be two digits: If the value of the element is not a valid month string, then set it to the empty string instead.>"); 90 91 test(function() { 92 assert_equals(document.getElementById("invalid_month_non_numerical").value, ""); 93 }, "Month should be two digits not characters: If the value of the element is not a valid month string, then set it to the empty string instead.>"); 94 95 test(function() { 96 assert_equals(document.getElementById("invalid_date_additional_tuples").value, ""); 97 }, "Value should be two parts: If the value of the element is not a valid month string, then set it to the empty string instead.>"); 98 </script> 99 </body> 100 </html>