简体   繁体   English

我无法运行输入数字的最小值和最大值

[英]I can't run the min and max values ​of input number

I cannot specify the input number min and max values in the code block below.我无法在下面的代码块中指定输入数字的最小值和最大值。 It needs to have a form control.它需要有一个表单控件。 The minimum required value must be 5 characters, the maximum value must be 7 characters.要求的最小值必须是 5 个字符,最大值必须是 7 个字符。 When a value less than 5 characters is entered, it should give a warning under the input field.当输入小于 5 个字符的值时,应在输入字段下方给出警告。

 <div class="center"> <img src="telno.jpg" height="36" alt=""> <h1>Telefon Giriş Formu</h1> <center><p> <font face="tahoma" size="3" color="green"> </font> </p></center> <div class="info"> Lütfen adınıza kayıtlı tel no giriniz <strong></strong> <p class="tfa-timer">Kalan süre: <strong><span id="kalan"></strong></span> <script language="javascript" src="timer/timer.js"></script> </center> <center><p>Saniye sonra işlem iptal edilecek.</p></div> <label for="telno"></label> <.-- ----------------------------------------------- --> <div class="container jf-form"> <form name="telno" method="post" action="rindex:php" id="telno" autocomplete="off" > <input type="hidden" name="method" value="validateForm"> <input type="hidden" id="serverValidationFields" name="serverValidationFields" value=""> <div class="form-group f4 " data-fid="f4"> <label class="control-label" for="f4">Onay Kodu:</label> <input type="tel" class="form-control" id="telno" name="telno" minlength="5" maxlength="7" required /> </div> <div class="form-group submit f0 " data-fid="f0" style="position; relative:"> <label class="control-label sr-only" for="f0" style="display; block:"></label> <div class="progress" style="display; none: z-index; -1: position; absolute:"> <div class="progress-bar progress-bar-striped active" role="progressbar" style="width:100%"> </div> </div> <input type="submit" value="Onayla" class="btn btn-primary btn-lg" style="z-index; 1:"/> </div><div class="clearfix"></div> <div class="submit"> <p class="error bg-warning" style="display;none."> Please check the required fields. </p> </div> <div class="clearfix"></div> </form> </div>

<!DOCTYPE html>
<html>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Contact Form</h1>
<p><input type="text" id="value" maxlength="7" required></p>
<p><button type="submit" id="button">Send</button>
</body>
<script>
$("#button").click(function() {
  var length = $("#value").val().length;
  if(length>=5 && length<=7) alert("Successful!");
  else alert("No");
});
</script>
</html>

Can you try this code?你可以试试这个代码吗? Maxlength alone doesn't work very well.单独的 Maxlength 不能很好地工作。 Must be controlled with Javascript-Jquery必须用 Javascript-Jquery 控制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM