如何验证动态文本框,以便没有两个文本框可以包含相同的值 [英] how to validate the dynamic textboxes so that no two textboxes can contain same value

查看:57
本文介绍了如何验证动态文本框,以便没有两个文本框可以包含相同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有动态文本框。如何验证动态文本框,以便没有两个文本框可以包含相同的值。我已经写过验证空复选框如下

Hi,
I have dynamic text boxes. how to validate the dynamic textboxes so that no two textboxes can contain same value. I have written validation for checking empty check box is as follows

for (var i = 0; i <= 20; i++)
        {
            var id = "txt" + i
            var txtbox = document.getElementById(id)
            if (txtbox) {

                if (txtbox.value != null && txtbox.value.trim() == "") {

                    alert("Serial Number field cannot be empty");

                    return false;

                }

            }

推荐答案

检查此链接hope这将有助于您为动态文本框添加验证。



动态创建ASP.NET服务器控件并通过在ASP.NET和C#.NET中附加事件进行验证 [ ^ ] < br $> b $ b

http://stackoverflow.com/questions/9871291/how-to-access-dynamically-generated-textboxes-and-apply-some-validation [ ^ ]
Check this link hope this will help you to add validation for Dynamic Textbox.

Dynamic creation of ASP.NET server controls on fly and doing validation by attaching Events in ASP.NET and C#.NET[^]

http://stackoverflow.com/questions/9871291/how-to-access-dynamically-generated-textboxes-and-apply-some-validation[^]


逻辑





  • 将所有 TextBox 值存储在数组中
  • 进行排序数组
  • 比较连续值
var allTextBoxes = [];


' input [type = text] ')。each( function (){
allTextBoxes.push(
('input[type=text]').each(function () { allTextBoxes.push(


这篇关于如何验证动态文本框,以便没有两个文本框可以包含相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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