form-validation-validity-rangeUnderflow.html (7711B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>The constraint validation API Test: element.validity.rangeUnderflow</title> 4 <link rel="author" title="Intel" href="http://www.intel.com/"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-validitystate-rangeunderflow"> 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="support/validator.js"></script> 10 <div id="log"></div> 11 <script> 12 var testElements = [ 13 { 14 tag: "input", 15 types: ["datetime-local"], 16 testData: [ 17 {conditions: {min: "", value: "2000-01-01T12:00:00"}, expected: false, name: "[target] The min attribute is not set"}, 18 {conditions: {min: "2000-01-01T12:00:00", value: ""}, expected: false, name: "[target] Value is empty string"}, 19 {conditions: {min: "2001-01-01 12:00:00", value: "2000-01-01T12:00:00"}, expected: false, name: "[target] The min attribute is an invalid local date time string"}, 20 {conditions: {min: "2000-01-01T11:00:00", value: "2000-01-01T12:00:00"}, expected: false, name: "[target] The min attribute is less than the value attribute"}, 21 {conditions: {min: "2001-01-01T23:59:59", value: "2000-01-01T24:00:00"}, expected: false, name: "[target] The value is an invalid local date time string(hour is greater than 23)"}, 22 {conditions: {min: "1980-01-01T12:00", value: "79-01-01T12:00"}, expected: false, name: "[target] The value is an invalid local date time string(year is two digits)"}, 23 {conditions: {min: "2000-01-01T13:00:00", value: "2000-01-01T12:00:00"}, expected: true, name: "[target] The value is less than min"}, 24 {conditions: {min: "2000-01-01T12:00:00.2", value: "2000-01-01T12:00:00.1"}, expected: true, name: "[target] The value is less than min(with millisecond in 1 digit)"}, 25 {conditions: {min: "2000-01-01T12:00:00.02", value: "2000-01-01T12:00:00.01"}, expected: true, name: "[target] The value is less than min(with millisecond in 2 digits)"}, 26 {conditions: {min: "2000-01-01T12:00:00.002", value: "2000-01-01T12:00:00.001"}, expected: true, name: "[target] The value is less than min(with millisecond in 3 digits)"}, 27 {conditions: {min: "10000-01-01T12:00:00", value: "2000-01-01T12:00:00"}, expected: true, name: "[target] The value is less than min(Year is 10000 should be valid)"}, 28 {conditions: {max: "8593-01-01T02:09", value: "8592-01-01T02:09"}, expected: false, name: "[target] The value is greater than max"} 29 ] 30 }, 31 { 32 tag: "input", 33 types: ["date"], 34 testData: [ 35 {conditions: {min: "", value: "2000-01-01"}, expected: false, name: "[target] The min attribute is not set"}, 36 {conditions: {min: "2000-01-01", value: ""}, expected: false, name: "[target] Value is empty string"}, 37 {conditions: {min: "2001/01/01", value: "2000-01-01"}, expected: false, name: "[target] The min attribute is an invalid date"}, 38 {conditions: {min: "2000-02-02", value: "2000-1-1"}, expected: false, name: "[target] The value attribute is an invalid date"}, 39 {conditions: {min: "988-01-01", value: "987-01-01"}, expected: false, name: "[target] The value is an invalid date(year is three digits)"}, 40 {conditions: {min: "2001-01-01", value: "2000-13-01"}, expected: false, name: "[target] The value is an invalid date(month is less than 12)"}, 41 {conditions: {min: "2001-01-01", value: "2000-02-30"}, expected: false, name: "[target] The value is an invalid date(date is less than 29 for Feb)"}, 42 {conditions: {min: "2000-01-01", value: "2000-12-01"}, expected: false, name: "[target] The min attribute is less than value attribute"}, 43 {conditions: {min: "2000-12-01", value: "2000-01-01"}, expected: true, name: "[target] The value attribute is less than min attribute"}, 44 {conditions: {min: "10000-01-01", value: "9999-01-01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"} 45 ] 46 }, 47 { 48 tag: "input", 49 types: ["time"], 50 testData: [ 51 {conditions: {min: "", value: "12:00:00"}, expected: false, name: "[target] The min attribute is not set"}, 52 {conditions: {min: "12:00:00", value: ""}, expected: false, name: "[target] Value is empty string"}, 53 {conditions: {min: "12.00.01", value: "12:00:00"}, expected: false, name: "[target] The min attribute is an invalid time string"}, 54 {conditions: {min: "12:00:01", value: "12.00.00"}, expected: false, name: "[target] The value attribute is an invalid time string"}, 55 {conditions: {min: "12:00:00", value: "13:00:00"}, expected: false, name: "[target] The min attribute is less than value attribute"}, 56 {conditions: {min: "13:00:00", value: "12"}, expected: false, name: "[target] The time missing second and minute parts is invalid"}, 57 {conditions: {min: "12:00:02", value: "12:00:00"}, expected: true, name: "[target] The value attribute is less than min attribute"}, 58 {conditions: {min: "12:00:00.2", value: "12:00:00.1"}, expected: true, name: "[target] The value is less than min(with millisecond in 1 digit)"}, 59 {conditions: {min: "12:00:00.02", value: "12:00:00.01"}, expected: true, name: "[target] The value is less than min(with millisecond in 2 digit)"}, 60 {conditions: {min: "12:00:00.002", value: "12:00:00.001"}, expected: true, name: "[target] The value is less than min(with millisecond in 3 digit)"}, 61 {conditions: {min: "12:00:00", value: "11:59"}, expected: true, name: "[target] The time missing second part is valid"}, 62 {conditions: {min: "14:00:00", max: "12:00:00", value: "12:00:00"}, expected: false, name: "[target] The time is max for reversed range"}, 63 {conditions: {min: "14:00:00", max: "12:00:00", value: "13:00:00"}, expected: true, name: "[target] The time is outside the accepted range for reversed range"}, 64 {conditions: {min: "14:00:00", max: "12:00:00", value: "14:00:00"}, expected: false, name: "[target] The time is min for reversed range"}, 65 {conditions: {min: "14:00:00", max: "12:00:00", value: "15:00:00"}, expected: false, name: "[target] The time is inside the accepted range for reversed range"}, 66 ] 67 }, 68 { 69 tag: "input", 70 types: ["number"], 71 testData: [ 72 {conditions: {min: "", value: "10"}, expected: false, name: "[target] The min attribute is not set"}, 73 {conditions: {min: "5", value: ""}, expected: false, name: "[target] Value is empty string"}, 74 {conditions: {min: "4", value: "5"}, expected: false, name: "[target] The min is less than value(integer)"}, 75 {conditions: {min: "-5.6", value: "-5.5"}, expected: false, name: "[target] The min is less than value(floating number)"}, 76 {conditions: {min: "0", value: "-0"}, expected: false, name: "[target] The min equals to value"}, 77 {conditions: {min: "5", value: "6abc"}, expected: false, name: "[target] The value is not a number"}, 78 {conditions: {min: "6", value: "5"}, expected: true, name: "[target] The value is less than min(integer)"}, 79 {conditions: {min: "-5.4", value: "-5.5"}, expected: true, name: "[target] The value is less than min(floating number)"}, 80 {conditions: {min: "1", value: "-.8"}, expected: true, name: "[target] The value is less than min(special floating number)"}, 81 {conditions: {min: "5e+2", value: "-5e-1"}, expected: true, name: "[target] The value is less than min(scientific notation)"} 82 ] 83 } 84 ]; 85 86 validator.run_test(testElements, "rangeUnderflow"); 87 </script>