我有一個簡單的HTML頁面,有兩個輸入文本框和一個提交按鈕。 當我點擊提交按鈕與無效的電子郵件地址它給了我一個錯誤消息。我怎樣才能實現相同的(顯示一個小的工具提示像彈出)爲數值的其他文本框?HTML5驗證的數值
下面是完整的HTML
<html>
<head>
<style>
body {
font: 1em sans-serif;
padding: 0;
margin : 0;
}
form {
max-width: 200px;
margin: 0;
padding: 0 5px;
}
p > label {
display: block;
}
input[type=text],
input[type=email],
input[type=number],
textarea,
fieldset {
/* required to properly style form
elements on WebKit based browsers */
-webkit-appearance: none;
width : 100%;
border: 1px solid #333;
margin: 0;
font-family: inherit;
font-size: 90%;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
input:invalid {
box-shadow: 0 0 5px 1px red;
}
input:focus:invalid {
outline: none;
}
</style>
</head>
<body><form>
<p>
<label for="t1">What's your age?</label>
<input type="number" id="t1" name="age">
</p>
<p>
<label for="t2">What's your e-mail?</label>
<input type="email" id="t2" name="email">
</p>
<p>
<button>Submit</button>
</p>
</form>
</body>
</html>
作爲一個側面說明:在案件99%,你要問的生日,而不是年齡。 –