简体   繁体   English

焦点jQuery

[英]Focusout jquery

i got the label of errore when i excute this as i use a time picker with a form field sharepoint control so当我执行此操作时,我得到了 errore 标签,因为我使用带有表单字段共享点控件的时间选择器,因此

this is my code of jquery validation这是我的 jquery 验证代码

    $("input[id*='ffEnTime']").focusout(function () {
        if ($("input[id*='ffEnTime']").val().trim() == "") {
            $("span[id*='lblEntTime']").show();
            $("span[id*='lblEntTime']").text("Write Entry Time");
        }
        else {
            $("span[id*='lblEntTime']").hide();
        }
    }); 

and the code of timepicker that i use以及我使用的时间选择器代码

$(document).ready(function () {
    //Start Validation at the after form loaded
    $("input[id*='ffPltNo']").attr("maxlength", "4");
    $("input[id*='ffIDNumber']").attr("maxlength", "10");
    $("input[id*='ffEnTime']").attr("autocomplete", "off");
    $("input[id*='ffEnTime']").attr("readOnly", "true");

    $("input[id*='ffEnTime']").timepicker({
        timeFormat: 'hh:mm p',
        minTime: '06:30:00', // 11:45:00 AM,
        maxHour: 24,
        maxMinutes: 30,
        startTime: new Date(0, 0, 0, 06, 0, 0), // 3:00:00 PM - noon
        interval: 30
    });

so it's look like this See pic所以它看起来像这样看图片

the errore is come because when i click on any time to choose it'll first focus out then the validation will execute finally it'll choose the time in that case i have to chose again to let the label disapper错误来了,因为当我点击任何时间选择它会首先聚焦然后验证将最终执行它会选择时间在这种情况下我必须再次选择让标签消失

any suggestions to replace focus out with something better ?有什么建议可以用更好的东西代替焦点吗?

i tried on change but doesnt work with me我尝试改变但对我不起作用

thanks in advanced.提前致谢。

Did u try你试过吗

 $("input[id*='ffEnTime']").on('input',function () {
//your validation function here
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM