现在我有(这是来自另一个已经完成的职能)
function validatelength() {
var length = parseInt(document.getElementById("length").value, 10);
var lengthError = document.getElementById("lengthError");
if (isNaN(length) || length < 50 || length > 220) {
lengthError.innerHTML = ">>Please enter your height<<";
return false;
} else {
lengthError.innerHTML = "";
}
return true;
}
这是我的小代码 检查字段是否包含一个人的长度。
Now for a text field (name/pre-name/notes) I want this too So far I have
function validatetext() {
var text = parseInt(document.getElementById("text").value, 10);
var textError = document.getElementById("textError");
if (isNaN(text) || text < 50 || text > 220) {
textError.innerHTML = ">>Please enter text only<<";
return false;
} else {
textError.innerHTML = "";
}
return true;
}
Could anyone help me completing the function? Thanks BTW: I can t use jquery. (not allowed to)