asp:CustomValidator错误消息未显示在chrome上 [英] asp:CustomValidator error messages not showing up on chrome

查看:70
本文介绍了asp:CustomValidator错误消息未显示在chrome上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用javascript中的ClientValidationFunction设置我的自定义错误消息。错误消息在IE8中正确显示但在IE9和chrome中没有显示

我的Validator

< pre lang =HTML> < asp:CustomValidator runat = server EnableClientScript = true ID = cvLogMsg ClientValidationFunction = user > < / asp:CustomValidator >





Javascript函数

  function  user(source,args){
var bool = ;
var errorMessage = ' ';
var oldpass = $ find(' txtOldPassword );
var currpass = document .getElementById(' oldpass');

var newpass = $ find(' txtNewPassword');
var confirmmpass = $ find(' txtConfirmPassword );
if (oldpass.get_value()。length> 0 ){
$(' #ELabel1')。removeClass(' lablelRed');
}
if (newpass.get_value()。length> 0 ) {
$(' #ELabel2')。removeClass(' lablelRed');
}
if (confirmpass.get_value()。length> 0 ) {
$(' #ELabel3')。removeClass(' lablelRed');
}
如果(oldpass!= null && oldpass.get_value ()。length> 0 || confirmpass!= null && confirmpass.get_value() .length> 0 || newpass!= null && newpass.get_value()。length > 0 ){
if (oldpass!= null && oldpass.get_value()。length == 0 ){
bool = ;
if document .getElementById(' lblCurrentPassMsg')!= null && document .getElementById(' lblCurrentPassMsg')。innerText){
errorMessage = document .getElementById(' lblCurrentPassMsg' ).innerText;
$(' #ELabel1')。addClass(' lablelRed');
}
}
其他 if (confirmmpass!= null && confirmpass.get_value()。length == 0 ){
bool = < span class =code-keyword> true
;
if document .getElementById(' lblConpassMsg')!= null && document .getElementById(' lblConpassMsg')。innerText){
errorMessage = document .getElementById(' lblConpassMsg' ).innerText;
$(' #ELabel3')。addClass(' lablelRed');
}
}
}


如果(bool == true ){

source.setAttribute( errormessage,errorMessage);

args.IsValid = false
}
else {
args.IsValid = true
}
}





以上设置''errorMessage''没有显示在IE9和chrome中它给出了空白消息。

解决方案

find(< span class =code-string>' txtOldPassword');
var currpass = document .getElementById(' oldpass');

var newpass =


find(' txtNewPassword');
var confirmmpass =


find(' < span class =code-string> txtConfirmPassword');
if (oldpass.get_value()。length> 0 ){


I am trying to set my custom error messages using ClientValidationFunction in javascript.The error messages shows up properly in IE8 but not in IE9 and chrome
My Validator

<asp:CustomValidator runat="server"  EnableClientScript="true" ID="cvLogMsg" ClientValidationFunction="user"></asp:CustomValidator>



Javascript function

function user(source, args) {
               var bool = false;
            var errorMessage = '';
            var oldpass = $find('txtOldPassword');
            var currpass = document.getElementById('oldpass');

            var newpass = $find('txtNewPassword');
            var confirmpass = $find('txtConfirmPassword');
            if (oldpass.get_value().length > 0) {
                $('#ELabel1').removeClass('lablelRed');
            }
            if (newpass.get_value().length > 0) {
                $('#ELabel2').removeClass('lablelRed');
            }
            if (confirmpass.get_value().length > 0) {
                $('#ELabel3').removeClass('lablelRed');
            }
            if (oldpass != null && oldpass.get_value().length > 0 || confirmpass != null && confirmpass.get_value().length > 0 || newpass != null && newpass.get_value().length > 0) {
                if (oldpass != null && oldpass.get_value().length == 0) {
                    bool = true;
                    if (document.getElementById('lblCurrentPassMsg') != null && document.getElementById('lblCurrentPassMsg').innerText) {
                        errorMessage = document.getElementById('lblCurrentPassMsg').innerText;
                        $('#ELabel1').addClass('lablelRed');
                    } 
                }
                 else if (confirmpass != null && confirmpass.get_value().length == 0) {
                        bool = true;
                        if (document.getElementById('lblConpassMsg') != null && document.getElementById('lblConpassMsg').innerText) {
                            errorMessage = document.getElementById('lblConpassMsg').innerText;
                            $('#ELabel3').addClass('lablelRed');
                        }
                    }
                }

         
            if (bool == true) {
                
                source.setAttribute("errormessage", errorMessage);
                         
                args.IsValid = false
            }
            else {
                args.IsValid = true
            } 
        }



above set ''errorMessage'' doesn''t shows up in IE9 and chrome it gives blank message.

解决方案

find('txtOldPassword'); var currpass = document.getElementById('oldpass'); var newpass =


find('txtNewPassword'); var confirmpass =


find('txtConfirmPassword'); if (oldpass.get_value().length > 0) {


这篇关于asp:CustomValidator错误消息未显示在chrome上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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