input attribute:
placeholder: The default value of the input box, showing descriptive text or prompt information to the user
autocomplete: Values are on and off. . "on" means that when the field is filled in and submitted and then returned to the page, the previously entered information will be displayed when entering again. off means closed, including the security of user input data. Default is on
autofocus: Set an input to automatically gain focus when the page loads. Note that the page can only set this attribute for one input. Setting multiple inputs is equivalent to no setting.
List feature and datalist: Add a drop-down list to an input box through list. . It is equivalent to the "auto-complete" function implemented in js, but it cannot perform fuzzy queries
If there are two values in the datalist: "a34343" and "24234", the user expects that both values will appear after entering 3, but in fact none of them will appear.
It requires a complete match. For example, if you enter a, the drop-down a34343 will appear, and then if you enter 4, the drop-down value will disappear.
required: This element must be filled in before the form is submitted, that is, it cannot be empty. Not recommended because of the prompt message 'Please fill in this field' unless there is an attribute that can replace the prompt message.
Pattern: A place to write regular patterns in the input tag. . The input control whose type is email or url has built-in related regular expressions. If the value does not match its regular expression, the form will fail the verification and cannot be submitted. .
It is not recommended to use it for elements whose type is email or url, because the prompt information is fixed and the regular pattern is fixed. . It is better to rewrite directly in js.
Some input settings:
rangeUnderflow limits the minimum value of the numerical control. Set min, input type="number" min="0" value="20"
rangeOverflow limits the maximum value of the numerical control. Set max, input type="number" max="100" value="20"
stepMismatch ensures that the input value conforms to the settings of min, max, and step. Set max min step, input type="number" min="0" max="100" step="10" value="20"
The following is a small function used by input=number:
function inputV(inpFields,tips){//input值范围判断。。0-100.正正数 /** * input值范围判断。。0-100.正正数 * range 范围:使用<input type="number" min="0" max="100"/> * if(inputV(v3,msgABC.t4)==false){return false;} * **/ var km=inpFields[0].validity,v3=inpFields.val(); console.log('不是数字:',km.badInput,'超出范围:',km.rangeOverflow,'小于最小值:',km.rangeUnderflow); if(km.badInput||km.rangeOverflow||km.rangeUnderflow){//a返回true 22返回true -1 返回 true alert(tips); return false; } if(isNaN(parseInt(v3))){ console.log('NaN 不判断.因为值为空'); return true; } else if(!!isNaN(v3)||parseInt(v3)!=parseFloat(v3)){//不是数字!!isNaN('v3') alert(tips); return false; } return true; }
list properties and datalist:
<input type="url" list="url_list" name="link" /> <datalist id="url_list"> <option label="W3School" value="http://www.w3school.com.cn" /> <option label="Google" value="http://www.google.com" /> <option label="Microsoft" value="http://www.microsoft.com" /> </datalist> <form action="http://localhost/test.php" method="post" id="register"></form> url:<input type="url" name="url" form="register" required/><br /> user:<input type="text" name="user" value="" form="register"/><br /> pwd:<input type="password" name="pwd" value="" form="register" /><br /> <select name="year" form="register"> <option value="1970">1970</option> <option value="1980">1980</option> <option value="1990">1990</option> </select> <input type="submit" value="注册" form="register"/>
Regular:
Email:< br />
Address:
DATE:
TIME:
MONTH:
Week:
Number:
Slider
Search:
Color:
Autofill form
<input type="text" name="auto" value="" list="movie" /> <datalist id="movie"> <option>11111111</option> <option>243234234</option> <option>3324234</option> </datalist>
Output form output
<form action="" method="post" oninput="result.value=parseInt(no1.value*no2.value)"> <input type="number" name="no1" value=""/> <input type="number" name="no2" value=""/> <output name="result" ></output> </form>
The above is the entire content of this article, I hope you all like it.