0

I try to validate Required fields in Java script. It will works fine on Chrome,Firefox.But it will not works for Textbox in IE at the same the scripts was works on DropDownlist validation on Submit button Click.

My Script For Validate Text Box:

function validateRecepitMaster() {
    if ((!IsBlank(Pay_Amount))) {
            ShowLabel(spPay_Amount);
             spPay_Amount.innerHTML = "*";
            Pay_Amount.focus();
            return false;
        }
}

function IsBlank(obj) {
    if (obj) {
            if ((obj.value.trim().length == 0) || (obj.value == null)) {
            obj.focus();
            return false;
        }
       return true;
    }
}

The Working Script for DropDown

if (Cust_Id.value == "") {
        ShowLabel(spCust_ID);
        spCust_ID.innerHTML = "*";
        Cust_Id.focus();
        return false;
    }

Above Both scripts woks fine on Chrome, Firefox, and not works at IE. Thanks in advance

4

2 回答 2

0

在运行你的之前添加以下脚本:

  String.prototype.trim=function()
{
     return this.replace(/(^\s*)|(\s*$)/g, '');
};
于 2013-11-06T10:50:46.290 回答
0

在控制台中查找 IE 引发的错误。

一个可能的候选人是:

obj.value.trim()

IE 可能不支持trim(还)

于 2013-11-06T10:37:44.690 回答