


JavaScript encounters some form attributes of HTML5_javascript skills
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
