如何从按钮/标签/框中检查金额的验证 [英] How Do I Check The Validation Of Amount From A Button/Label/Box
问题描述
例如:我有一个标签,金额是20000
现在每当我尝试输入的金额超过这个金额时(即20000)来自账户
然后它不应该接受我将输入的金额(即20001 +)。
添加以下内容验证控件的属性
onblur =javascript:return validateAmount();
某处页面添加以下内容:
函数validateAmount(){
var lbl = document.getElementById(yourlabelID);
if(lbl!= null){
if(lbl.value& gt; 20000){
alert(你可能不输入金额超过20000!);
返回false;
}
}
返回true;
}
如果使用jQuery,可以用
替换getElementById for example : I have a label where amount is 20000 这篇关于如何从按钮/标签/框中检查金额的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
now whenever i will try to enter more than that amount(i.e 20000) from account
then it should not accept my amount which i will enter(i.e 20001+).Add the following attribute on your validated control
onblur="javascript: return validateAmount();"
somewhere on the page add the following:
function validateAmount() {
var lbl = document.getElementById("yourlabelID");
if (lbl != null) {
if (lbl.value > 20000) {
alert("You may not enter the amount above 20000!");
return false;
}
}
return true;
}
if you use jQuery you can replace getElementById with("#yourlabelID") and lbl.value with lbl.val()