How to make allowed values are 1 to 7, n and blank only?
I am just new with javascript and I only need to allow values when submitted. Allowed values are 1 to 7, n and blank only... How to restrict others? I just started below to allow 1 to 7 but for n and blank, I don't know yet.
JAVASCRIPT:
Code:
function verify(frm) {
if (frm.sc_scores.value > 7 || frm.sc_scores.value <= 0) {
self.alert(frm.sc_scores.value + " is an invalid value! Allowed values are 1 to 7, n and blank");
frm.sc_scores.focus();
}
}
HTML:
Code:
<input type="text" name="sc_scores" id="sc_scores" maxlength="1" size="2" value="<%= number %>" />
Code:
<input type="button" onClick="verify(this.form)" value="Edit" />
Please help... Thanks....