4 <script src=
"../../../resources/js-test.js"></script>
8 description('Type=number field should not accept invalid numbers though a user can type such strings');
10 var parent
= document
.createElement('div');
11 document
.body
.appendChild(parent
);
12 parent
.innerHTML
= '<input type=number id=number value=256>';
14 var input
= document
.getElementById('number');
16 function checkIt(what
, sample
, expected
)
19 document
.execCommand("SelectAll");
20 document
.execCommand("InsertText", false, sample
);
22 debug('enter "' + sample
+ '" for ' + what
);
23 shouldBeEqualToString('input.value', expected
);
26 debug("\nNo restriction");
27 checkIt('noRange', "512", "512");
28 checkIt('typeMismatch', "+++", "");
29 checkIt('empty', "", "");
31 debug("\nmin/max/step");
32 input
.setAttribute("min", "0");
33 input
.setAttribute("max", "100");
34 input
.setAttribute("step", "1");
35 checkIt("randerUnderflow", "-1", "-1");
36 checkIt("minimum", "0", "0");
37 checkIt("inRange", "25", "25");
38 checkIt("inRange", "50", "50");
39 checkIt("stepMismatch", "10.5", "10.5");
40 checkIt("maximum", "100", "100");
41 checkIt("rangeOverflow", "200", "200");
42 checkIt("typeMismatch", "abc", "");
43 checkIt("empty", "", ""); // empty