【发布时间】:2014-04-10 06:04:36
【问题描述】:
我有多个文本框,其格式应为 XXX.XX,其中 X 可以是用户输入的任何数字。我也有一个提交按钮。因此,在提交之前,如果文本框具有值,则必须遵循给定的格式。 我正在像下面这样进行。下面是我想要的代码+步骤:::
我必须遍历 div 元素并检测每个文本框,然后对于每个文本框,如果它有值,我必须对其进行验证。
<div id="DivFeeContent" style="float: left; width: 100%;">
<input type="text" style="width: 95px;" maxlength="3" class="validate" />
<input type="text" style="width: 95px;" maxlength="3" class="validate" />
<input type="text" style="width: 95px;" maxlength="3" class="validate" />
<input type="text" style="width: 95px;" maxlength="3" class="validate" />
</div>
代码
function CheckpricePrice() {
$("#DivFeeContent input:text").each(function () {
var Value= $(this).val();
if(Value!='')
{
// Check the Format . It should be XXX.XX
if (Value == matches)
{
}
else{ return false;}
}
});
Here Goes Submission of the form
}
【问题讨论】:
标签: javascript jquery logic