如何根据另一个文本框验证文本框? [英] How to Validate Text box on depend of another Text box?

查看:83
本文介绍了如何根据另一个文本框验证文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行学生费用详细信息的计算,有两个文本框,一个自动固定(禁用)为Rs.5000,如果我在另一个文本框中输入低于Rs.5000值的值,那么它将计算减法和在结果文本框中显示余额。如果我输入的值高于Rs.5000,则不应在第二个文本框中取该值。我想根据第一个文本框值验证文本框。

I am Performing Calculation of Student fee Details,There are Two Text boxes,one which is automatically fixed(disabled)as Rs.5000,If i enter value below Rs.5000 value on another Text box then it will calculate subtraction and show balance in result text box.If i enter value above Rs.5000 it should not take that value in second text box.I want to validate text box depending on first text box value.

推荐答案

function calc() {       
        var x = trim(document.getElementById("<%=txtFirst.ClientID%>").value);
        var y = trim(document.getElementById("<%=txtSecond.ClientID%>").value);
        if (parseInt(y) > parseInt(x)) {
            alert("Less than 5000 is allow");
            document.getElementById("<%=txtSecond.ClientID%>").value = "";
            document.getElementById("<%=txtSecond.ClientID%>").focus();
            return false;
        }
        else
        {
           var Remaining = parseInt(x) - parseInt(y)
           document.getElementById("<%=txtResult.ClientID%>").value = Remaining ;
        }
        return true;
    }

and on your second text box  call function when text box is blur

 <asp:textbox id="txtSecond" runat="server" onblur="calc()" xmlns:asp="#unknown">   </asp:textbox>  


尝试

Try


textbox2id)。 focusOut(function(){
if (!(
("textbox2id").focusOut(function(){ if(!(


这篇关于如何根据另一个文本框验证文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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