RangeValidator单击“提交”按钮时触发。 [英] RangeValidator Fires when the Submit Button is clicked.

查看:91
本文介绍了RangeValidator单击“提交”按钮时触发。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个RangeValidators。他们正在开火但不正确。当用户将他们的号码和标签输入到下一个文本框时,如果新号码比旧号码高40%,则会触发RV。如果新号码比旧号码高50%,则其他RV也是如此。当用户输入与旧号码相同的号码并单击提交时,将触发RV。我做错了什么计算?如果有40%和50%的增加,我只想解雇房车。



这是房车增加40%:

I have two RangeValidators. They are firing but not correctly. When the user enters their numbers and tabs to the next textbox the RV will fire if the new number is 40% higher than the old number. The same goes for the other RV if the new number is 50% higher that the old number. When the user enters the same number as the old number and clicks Submit the RV fires. What calculation did I do wrong? I just want to fire the RV if there is an 40% and 50% increase.

This is the 40% increase RV:

int itxtVal6 = Convert.ToInt32(TextBoxLY1.Text);
        int iminVal6 = itxtVal6;
        int imaxVal6 = itxtVal6 * (140 / 100);
        RangeValidatorLY1.MinimumValue = iminVal6.ToString();
        RangeValidatorLY1.MaximumValue = imaxVal6.ToString();





这是RV增加50%:



This is the 50% increase RV:

int itxtVal12 = Convert.ToInt32(TextBoxLY2.Text);
        int iminVal12 = itxtVal12;
        int imaxVal12 = itxtVal12 * (150 / 100);
        RangeValidatorLY2.MinimumValue = iminVal12.ToString();
        RangeValidatorLY2.MaximumValue = imaxVal12.ToString();

推荐答案

这是基于上面的评论,说我不喜欢几年前不再使用Microsoft Validators,几年前放弃了它们。



我表示我使用JQuery和Javascript来验证表单。所以...



你从这里开始,

http://learn.jquery.com/about-jquery/how-jquery-works/ [ ^ ]



使用创建空白jscript文件解决方案资源管理器,将其命名为rangeValidator.js或其他内容,并将文件从解决方案资源管理器拖到head标记中。

This is based on the comment above, saying that I don't use the Microsoft Validators anymore, gave up on them years ago.

I indicated that I use JQuery and Javascript to validate forms. So ...

You start here,
http://learn.jquery.com/about-jquery/how-jquery-works/[^]

Create a blank jscript file using solution explorer, name it rangeValidator.js or something, and drag the file from the solution explorer into the head tag.
<head>
 <script src="jquery.js"></script>
 <script src="rangeValidator.js"></script>
</head>





编写脚本



Write your script

function validate_40() {
    var vFlag = true;
    var itxtVal6_txt, itxtVal6_int, iminVal_int, imaxVal6_int;
    itxtVal6_txt =


('#TextBoxLY1')。val();
iminVal6_int = parseInt(itxtVal6_txt);
imaxVal6_int = parseInt(iminVal6_int * 140/100);
if(!some formula){
vFlag = false;
}
返回vFlag;
}
('#TextBoxLY1').val(); iminVal6_int = parseInt(itxtVal6_txt); imaxVal6_int = parseInt(iminVal6_int * 140 / 100); if (!some formula) { vFlag = false; } return vFlag; }





然后按下按钮



Then on your button

<asp:textbox id="TextBoxLY1" runat="server" xmlns:asp="#unknown"></asp:textbox>
<asp:button id="submit" runat="server" onclientclick="return validate_40();" xmlns:asp="#unknown"></asp:button>





我不打算解决这个问题,也许有人可以编辑它并修复任何错误或扩展它。



I'm not going to tackle the formula, perhaps someone can edit this and fix any errors or expand on it.


这篇关于RangeValidator单击“提交”按钮时触发。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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