gpt4 book ai didi

javascript - 接受值 100 及以上的文本框

转载 作者:行者123 更新时间:2023-11-30 09:46:30 28 4
gpt4 key购买 nike

这是我的文本框:

textbox

这是它的代码:

        <!-- Preferred credit limit --> 
<div class="signup-card-section">
<h2 class="accordion-header boldtext">Tell Us Your Preferred Credit Limit</h2>
<div class="column-control no-padding twelve colgrid">
<fieldset>
<div class="row">
<p class="text-red">(Choose one)</p>
<p>My Preferred Credit Limit<span class="text-red">*</span></p>
<br>
<input type="radio" name="prefcreditlimit" checked="checked" value="yesprefcreditlimit" id="yesprefcreditlimit">
<span class="radiotextdeco">S$</span> <input type="text" class="input numeric-only nodecimal width30" name="prefcreditlimitval" id="prefcreditlimit" min="100"> <span style="font-size:12px;"> (Must be in multiples of 00’ and a minimum of S$100)</span><br><br>
<input type="radio" name="prefcreditlimit" checked="checked" value="noprefcreditlimit"> <span class="radiotextdeco">I dont have a preferred credit limit and agree to any credit limit determined</span><br><br>
<p><strong>Note:</strong> Principal applicant and Suplementary applicant will be granted the preferred credit limit of any limit determined by the bank, whichever is lower.</p>
</div>
</fieldset>
</div>
</div>

如果输入的值不是 00 的倍数或最低 100 新元,则会出现错误消息:“您的首选信用额度必须是 00 的倍数和最低 100 新元。因为我将最小值设置为 100。当用户输入小于 100 时会出现一条错误消息。现在的问题是,我不确定如何检查 00 的验证

如有任何帮助,我们将不胜感激。

最佳答案

使用 <input type="number">连同 minstep属性:

<input type="number" name="prefcreditlimitval" min="100" step="100">

如果用户输入的值小于最小值或不是步长的倍数,浏览器的验证将阻止提交表单。在不支持验证的浏览器中,您可以使用 polyfill(如 this one )。

您可以测试验证(尽管 SO 不允许运行表单):

input:invalid {
border-color: red;
}
Input multiples of 100<br><br>
<input type="number" name="test" min="100" step="100">

关于javascript - 接受值 100 及以上的文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38761470/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com