Html 有没有办法在不同的文本框上设置多个数字限制?
我正在做一个基本的评分单位。我有文本框,希望用户只在某个集合中输入数字,如果输入了集合之外的数字,就会出现一个错误,说“只能输入这些数字”。不过有多组数字。有可能不止一个吗?这是我的密码:Html 有没有办法在不同的文本框上设置多个数字限制?,html,Html,我正在做一个基本的评分单位。我有文本框,希望用户只在某个集合中输入数字,如果输入了集合之外的数字,就会出现一个错误,说“只能输入这些数字”。不过有多组数字。有可能不止一个吗?这是我的密码: <!DOCTYPE html> <html> <body> <p align="right"> Dance Number: <input type="text"size="3"></p> <h1><ins>Jud
<!DOCTYPE html>
<html>
<body>
<p align="right"> Dance Number: <input type="text"size="3"></p>
<h1><ins>Judge 1</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
<form>
<p> Technique: <input type="text"size="3"> /35</p>
<p> Choreography: <input type="text"size="3"> /15</p>
<p> Performance: <input type="text"size="3"> /25</p>
<p> Precision: <input type="text"size="3"> /15</p>
<p> Total Points: <input type="text"size="3"> /90</p>
<h1><ins>Judge 2</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
</form>
<form>
<p> Technique: <input type="text"size="3"> /35</p>
<p> Choreography: <input type="text"size="3"> /15</p>
<p> Performance: <input type="text"size="3"> /25</p>
<p> Precision: <input type="text"size="3"> /15</p>
<p> Total Points: <input type="text"size="3"> /90</p>
<h1><ins>Judge 3</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
</form>
<form>
<p> Technique: <input type="text"size="3"> /35</p>
<p> Choreography: <input type="text"size="3"> /15</p>
<p> Performance: <input type="text"size="3"> /25</p>
<p> Precision: <input type="text"size="3"> /15</p>
<p> Total Points: <input type="text"size="3"> /90</p>
<p> Over All Score:<input type="text"size="3"> /90</p>
<p> Award Assigned:</p>
<input type="submit" />
</form>
<script>
</script>
</body>
</html>
舞蹈编号:
法官1
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
法官2
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
法官3
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
总分:/90分
分配的奖项:
技术:/35
编舞:/15
性能:/25
精度:/15
斜杠和数字旁边有文本框只要你可以,我不知道你是否可以使用css,但可以使用javascript,按on键。例如:
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>insert page</title></head>
<body onkeypress="alert("HELL")">
<textarea id='textbox1' onkeypress="countLetters(this, 15)">
</textarea>
<textarea id='textbox2' onkeypress="countLetters(this, 25)"></textarea>
<script type='text/javascript'>
var textbox1 = textbox2 = textbox3 = textbox4 = 0;
function countLetters(element, limit) {
if(element.id == 'textbox1') {
if(element.value.length > limit) {
element.disabled=true;
} else {
textbox1++;
}
} else if (element.id == 'textbox2') {
if(element.value.length > limit) {
element.disabled=true;
} else {
textbox2++;
}
}
}
</script>
</body>
</html>
插入页面
var textbox1=textbox2=textbox3=textbox4=0;
函数计数字母(元素、限制){
如果(element.id='textbox1'){
如果(element.value.length>limit){
element.disabled=true;
}否则{
textbox1++;
}
}else if(element.id='textbox2'){
如果(element.value.length>limit){
element.disabled=true;
}否则{
textbox2++;
}
}
}
我会使用输入类型编号(因为它们是分数)并设置浏览器强制执行的最大值和最小值
html
<!DOCTYPE html>
<html>
<body>
<p align="right"> Dance Number: <input type="number"size="3"></p>
<h1><ins>Judge 1</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
<form>
<p> Technique: <input type="number" min="0" max="35"> /35</p>
<p> Choreography: <input type="number" min="0" max="15"> /15</p>
<p> Performance: <input type="number" min="0" max="25"> /25</p>
<p> Precision: <input type="number" min="0" max="15"> /15</p>
<p> Total Points: <input type="number" min="0" max="90"> /90</p>
<h1><ins>Judge 2</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
</form>
<form>
<p> Technique: <input type="number" min="0" max="35"> /35</p>
<p> Choreography: <input type="number" min="0" max="15"> /15</p>
<p> Performance: <input type="number" min="0" max="25"> /25</p>
<p> Precision: <input type="number" min="0" max="15"> /15</p>
<p> Total Points: <input type="number" min="0" max="90"> /90</p>
<h1><ins>Judge 3</ins></h1>
<p> Comments</p>
<textarea name="myTextBox" cols="50" rows="5">
</textarea>
<br />
</form>
<form>
<p> Technique: <input type="number" min="0" max="35"> /35</p>
<p> Choreography: <input type="number" min="0" max="15"> /15</p>
<p> Performance: <input type="number" min="0" max="25"> /25</p>
<p> Precision: <input type="number" min="0" max="15"> /15</p>
<p> Total Points: <input type="number" min="0" max="90"> /90</p>
<p> Over All Score: <input type="number" min="0" max="90"> /90</p>
<p> Award Assigned:</p>
<input type="submit" />
</form>
<script>
</script>
</body>
</html>
舞蹈编号:
法官1
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
法官2
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
法官3
评论
技术:/35
编舞:/15
性能:/25
精度:/15
总分:/90
总分:/90分
分配的奖项:
您能否提供一个或两个输入的示例,以及哪些数字是有效的?舞蹈编号:Judge 1 Comments Technical:/35 Choreography:/15 Performance:/25 Precision:/15 Total Points:/90我建议您现在也看看javascript中的自动汇总-您可以在下一步询问相关问题或搜索很抱歉,我以前的代码不起作用,我在手机上输入了所有代码,并复制了一些其他代码。注意,现在变量不在函数中,这将有助于增加它们;)我们完全禁用输入,而不是使用字符串缩短。HTML5:)起到了解救作用:)我不知道输入类型可以是数字。