This chapter introduces the following new form elements:
•datalist
•keygen
•output
Browser support
Input type IE Firefox Opera Chrome Safari
datalist element The datalist element specifies a list of options for the input field.
The list is created through the option element within datalist.
If you need to bind the datalist to the input field, please use the list attribute of the input field to reference the id of the datalist:
The code is as follows:
Webpage : <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>
Tip: The option element must always set the value attribute.
keygen element The keygen element is used to provide a reliable way to authenticate users.
The keygen element is a key-pair generator. When the form is submitted, two keys are generated, one is the private key and the other is the public key.
The private key is stored on the client, and the public key is sent to the server. The public key can be used later to verify the user's client certificate.
Currently, browser support for this element is poor enough to make it a useful security standard.
code show as below:
<form action="demo_form.asp" method="get">
Username: <input type="text" name="usr_name" />
Encryption: < ;keygen name="security" />
<input type="submit" />
</form>
##output element
The code is as follows:
<output id="result" onforminput="resCalc()"></output>
Example:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> </head> <body> <form action="demo_keygen.php" method="get"> 用户名: <input type="text" name="usr_name"> 加密: <keygen name="security"> <input type="submit"> </form> </body> </html>
<!doctype html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> </head> <body> <form action="" id="myform" oninput="num.value=parseInt(num1.value)+parseInt(num2.value)"> <input type="number" id="num1">+ <input type="number" id="num2">= <output name="num" for="num1 num2"></output> </form> </body> </html>