我想比较所有文本框。我将如何完成? [英] I Want To Compare All Textboxes To Each Other. How Would I Done?

查看:91
本文介绍了我想比较所有文本框。我将如何完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作月薪计算器。



我在点击按钮时添加多个文本框。我在每个文本框上都使用了datepicker。

现在我希望在另一个按钮点击时将所有文本框值相互比较。如果两个或多个文本框值匹配,则警报应显示不允许相同日期。



我将如何做到这一点?

帮助我thanx。

i am trying to make month salary calculator.

i add multiple textboxes on button click . and i use datepicker on every textbox.
now i want compare all textboxes value to each other on another buttton click . if two or more textboxes values are match then alert should be show "same date not allowed".

how would i done this?
Help me thanx.

推荐答案





你可以使用Jquery类来做到这一点,



为同一个类命名你要比较的文本框



在jquery中找到具有类名的文本框,并比较存在的值

与其他文本框。 br />


捕获文本框中不同值的文本框的事件



为该类文本框创建函数名字onblur,onfocusout,ontabout

参考下面的代码,代码我根据syntex进行更改,但想法是捕获你要比较的任何文本框的更改



Hey

You can do this using Jquery class,

Assign same class name to the textboxes you want to compare

Find the textbox having the class name in the jquery and compare for the value present
with other textbox.

Capturing the event for those textboxes different value in the textbox

Create functions for those textbox with that class name onblur,onfocusout,ontabout
refer below code, code me change as per syntex but the idea is to capture the change of any no of textbox which you want to compare


('name * =abc')。on('blur','tabout','onfocusout') function {}



在jquery中声明一个临时变量捕获temp变量中的值


每次用户更改值时,将值与之前的值进行比较

一旦值不同,警告用户同一数据不允许





基本上上面的jquery函数选择所有名称为abc的元素,然后捕获上述事件的数据任何类名与abc类似的文本框。如果该值与其他先前值不同,则会抛出警报。
('name*="abc"').on('blur','tabout','onfocusout')function{}

Declare a temp variable in jquery capture the value in the temp variable

every time the user changes the value compare the value with the previous value
once the value differs alert the user with the message "same data not allowed"


Basically the jquery function above selects all the elements having name abc, then captures the data on the above mentioned events for any of the textbox having class name similar to abc. If the value is different that other previous values it will throw alert.


这篇关于我想比较所有文本框。我将如何完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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