如何从按钮/标签/框中检查金额的验证 [英] How Do I Check The Validation Of Amount From A Button/Label/Box

查看:58
本文介绍了如何从按钮/标签/框中检查金额的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:我有一个标签,金额是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
(#yourlabelID)和lbl.value与lbl.val()


for example : I have a label where amount is 20000


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()


这篇关于如何从按钮/标签/框中检查金额的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆