Html5's placeholder attribute of IE compatible implementation code
- 2020-03-30 03:48:22
- OfStack
HTML5 makes many enhancements to the Web Form, such as the new type type input, Form Validation, and so on.
For example: < Input id="t1" type="text" placeholder=" please type "/>
Directly copy the code down, save a js file reference, do not have to do any processing, super convenient!
Ex: this does make IE's Input display placeholder attributes, but if there is only one Input on the page, it is fine, if there are multiple inputs, if the Input does not fill in any value, then its empty Input will automatically fill in placeholder values in the value, resulting in an error. For example:
<input type="text" placeholder=" Input commodity code " name="goodscode" id="goodscode" value="123" />
<input type="text" placeholder=" Enter product name " name="goodsname" id="goodsname" value=" Enter product name " />
The solution is to judge in the background, may be able to solve in the above js file, later study ~!