我有一个标有“分数”的文本框。我希望用户输入一个介于 0 和 100 之间的值。如何验证用户提供的值?
HTML:
<div class="editor-label"> Score </div>
<div class="editor-field">
<input type="text" name="Score" id="Score" maxlength="25" />
<span id="ScoreError" class="error"></span>
</div>
到目前为止我尝试了什么:
var num = document.getElementById("Score").value;
if (num < 0 || num > 100){
document.getElementById("ScoreError").innerHTML = "- Score is required.";
alert("Enter a Score thats between 0 to 100")
isValidForm = false;
}