Client Script for form validation not working

人盡茶涼 提交于 2021-01-29 12:43:17

问题


I have a client Script for which I have to do validation using validatefield event. I have written the code . The condition is - If the date is other than Sunday, it should show a pop-up. But the pop-up is not showing. I have tried to achieve using the try and catch block, but it didn't work.Please look and suggest where I am going wrong

/**
  *@NApiVersion 2.0
  *@NScriptType ClientScript
  */

define(["N/currentRecord","N/search","N/runtime","N/record","N/ui/dialog"], function print(cr,search,runtime,record,dialog){
    
    var exports = {};
    
    function printMessage (context){


  var startDate = context.currentRecord.getValue({
            "fieldId": "custpage_start_date"
        })

        var endDate = context.currentRecord.getValue({
            "fieldId": "custpage_end_date"
        })

        var date =  new Date(startDate);
        var day = date.getDay();
  
        var options = {
      title: 'Date entered',
      message: 'Is Not correct'
    };
         
        console.log(day);
        
          try{
           if(day==0 && (startDate!='' || startDate!=undefined)){
             
             return true;
             
           }
            console.log("Inside try block");
          }
          catch(e){
            log.error({
          title: e.name,
          details: e.message
         });
            dialog.alert(options);
            console.log("Inside catch block");
            
          }
      console.log("Outside")


}

 exports.validateField = printMessage;
 return exports;

    
})


来源:https://stackoverflow.com/questions/64301854/client-script-for-form-validation-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!