[英]Validation on input text fields in html
Suppose:认为:
There's First Name: (box for input first name)有名字:(输入名字的框)
Requirement: i cannot left this field empty,error message should generate if i left it empty.要求:我不能将此字段留空,如果我将其留空,则应生成错误消息。
Solve this only through HTML只能通过 HTML 解决这个问题
<input>
has a required
attribute, as such: <input>
有一个required
的属性,例如:
<input type="text" name="username" required>
This will raise an error if the user tries to submit the form without first filling out the input.如果用户在没有先填写输入的情况下尝试提交表单,这将引发错误。 That being said, please google this next time.
话虽如此,请下次谷歌。
<form>
first name <input type="text" name="firstname" required>
<input type="submit">
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.