HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>文本框 - 表单验证</title>
<link rel="stylesheet" href="https://cdn.w3cbus.com/library/mdui/1.0.2/css/mdui.min.css"/>
</head>
<body>
<div class="mdui-container">
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">User name</label>
<input class="mdui-textfield-input" type="text" required/>
<div class="mdui-textfield-error">用户名不能为空</div>
</div>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">Email</label>
<input class="mdui-textfield-input" type="email" required/>
<div class="mdui-textfield-error">邮箱格式错误</div>
</div>
<div class="mdui-textfield mdui-textfield-floating-label">
<label class="mdui-textfield-label">Password</label>
<input class="mdui-textfield-input" type="text" pattern="^.*(?=.{6,})(?=.*[a-z])(?=.*[A-Z]).*$" required/>
<div class="mdui-textfield-error">密码至少 6 位,且包含大小写字母</div>
<div class="mdui-textfield-helper">请输入至少 6 位,且包含大小写字母的密码</div>
</div>
</div>
<script src="https://cdn.w3cbus.com/library/mdui/1.0.2/js/mdui.min.js"></script>
</body>
</html>