0

首先,在页面加载时,我将默认水印设置如下:

function AddWatermarksDataEntry() {
    initialWatermarks = new Array();
    initialWatermarks.push(new Array("P1_BIRTHDATE_MASK", "__/__/____"));
    initialWatermarks.push(new Array("P2_BIRTHDATE_MASK", "__/__/____"));
    initialWatermarks.push(new Array("P1_VALIDFROM_MASK", "~#SF_DD/MM/YYYY~"));
    initialWatermarks.push(new Array("P2_VALIDFROM_MASK", "~#SF_DD/MM/YYYY~"));
    initialWatermarks.push(new Array("P1_IDENTITYDOCUMENTNUMBER", " "));
    initialWatermarks.push(new Array("P2_IDENTITYDOCUMENTNUMBER", " ")); //***-*******-**
    initialWatermarks.push(new Array("P1_VAT", "~#SF_9OR10_DIGIT~"));
    initialWatermarks.push(new Array("P2_VAT", "~#SF_9OR10_DIGIT~"));
    Watermarker(initialWatermarks);
}

稍后,当我为我的身份证类型调整下拉值时,我会执行以下操作:

if(newIdentityDocumentType == "1")
            {
                ChangeIdentityDocumentNumberField($('#'+ whichPerson +'_IDENTITYDOCUMENTNUMBER'), $('#'+ whichPerson +'_NATIONALITY'), watermarkIdentityDocumentNumberBelgian, foreignPersonWaterMark, 14, 14);
                $('#'+ whichPerson +'_IDENTITYDOCUMENTNUMBER').mask('999-9999999-99');
                $('.'+ whichPerson + '.identityDocumentNumber').text('e.g. 123-456789112-34');
            }

我检查用户是否选择了正确的身份证件类型。如果他或她这样做了,则更改输入字段的属性,具体来说,我希望调整水印。

ChangeidentityDocumentField 方法调用将更改水印的方法,如下所示:

function ChangeIdentityDocumentNumberField(IdentityDocumentNumberField, NationalityField, WatermarkBelgian, WatermarkForeign, MaximumBelgian, MaximumForeign) {
    if (NationalityField.val() == "0") {
        //omitted code
        ChangeWatermark(IdentityDocumentNumberField, WatermarkBelgian);
    } else {
        //omitted code
        ChangeWatermark(IdentityDocumentNumberField, WatermarkForeign);
    }
}

function Watermarker(newWatermark) {
for (i = 0; i < newWatermark.length; i++) {
    $('#' + newWatermark[i][0]).Watermark(newWatermark[i][1]);

    $('#' + newWatermark[i][0]).blur(function (item, watermark) {
        return function () {
            //if ($('#' + item).val() == '') {
                $('#' + item).Watermark(watermark);

            //};
        };
    } (newWatermark[i][0], newWatermark[i][1]));
};

}

有了这个方法,问题就来了,当我在一个输入框想出去的时候,调用上面的函数,一切顺利,我看到添加了水印(我在调试的时候,但是,突然,当代码跳转到:

} (newWatermark[i][0], newWatermark[i][1]));

我的水印被重置为默认值!?

4

1 回答 1

0

我已经通过删除上面的代码并用占位符替换它来解决这个问题。但是我遇到了一个新问题: Change placeholder text with jquery also auto-update in IE

于 2013-06-03T18:48:32.840 回答