本文介绍了下拉框 - 使用jQuery.tools.validator需要验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用验证。
我试图用验证验证没有成功dropdownbox。

I'm using jQuery tools validator for my web app in ASP.net MVC4.I'm trying to validate dropdownbox using validator without success.

我已经通过的问题,但它这么想的解决了我问题。

I've gone through this question, but it dosen't solved my problem.

我的code是如下图所示。

my code is as below.

$.tools.validator.fn("select[required=required]", function(input, value) {
            // If the first item in the list is selected return FALSE
            alert("Inside required of dropdown");
            if(input[0].options[0].selected)
            {
                alert("returning false");
                en: "Please select value from this drop down"
            }
            else
            {
                alert("returning true");   
                return true;
            }
        });

它提醒所有的警报,但忽略了最低虚假显示错误信息,而关于选择的元素它选择项的值作为验证消息触发。

it does alerts all the alert but it dosen't show error message on false, rather on selecting element it does fires selected item's value as validation message.

任何帮助将appriciated。

any help would be appriciated.

推荐答案

问题是与我的html code,居然给我分配所需=必需的,但是当我做过tools.validator.js一些见解,我发现为了处理所需的功能如下

Problem was with my html code, actually I assigned required="required" but when i done some insight in tools.validator.js, I found function to handle required as following

注意:我从网上下载

所以,当需要分配I =需要,不是要求作为价值在arugument B中的函数传递,并返回相同的这是造成问题的原因。

so, when i assign required="required", than "required" is passed as value to the function in arugument b, and same was returned which was causing the problem.

这样的解决方案是将所需=true或要求=假,所以真/假将被传递参数b,来运作,同时将b返回。

so the solution is to pass required="true" or required="false", so "true"/"false" will be passed to function in argument b and same will b returned.

这篇关于下拉框 - 使用jQuery.tools.validator需要验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 09:07