Validate Past Date Using Script Include and On change client script

sushma9
Tera Contributor

Hi All,

 I am trying to validate the past date using script include and on change  client script but i am not getting any thing .Please let me know what are the modifications has to be done in my code .

  Script Include :

var validatearrivaldate = Class.create();
validatearrivaldate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    validateArrivalPastDate: function() {
        var actualArrivalDate = this.getParameter('sysparm_arravaldate');
        var tDate = new GlideDateTime();
        var dur = new GlideDuration();
        dur = GlideDateTime.subtract(actualArrivalDate, tDate);
        if (actualArrivalDate < tDate ){
        return true;
    } else {
        return false;
    }
},
type: 'validatearrivaldate'

 

 

 

Client Script :

 var ga = new GlideAjax("validatearrivaldate"); // Adding the script include name
 ga.addParam("sysparm_name""validateArrivalPastDate"); // adding the function Name
 ga.addParam("sysparm_arravaldate",g_form.getValue("u_arrival_date")); //getiing the value from the field.
 ga.getXML(validatedate);
 function validatedate(response){
     var answer = response.responseXML.documentElement.getAttribute("answer");
     if(answer = true){
alert("Arrival date should not be in the Past Date .Please select the Future Date !!!");
g_form.clearValue('u_arrival_date'); 
 }

 

2 REPLIES 2

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Didn't you already had a topic open for this? Yesterday or the day before.

 

Please don't raise your topics over and over. Just handle the existing topic.

 

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

@Mark Roethof 

 

I have achieved that by using On change client script but I am new to service now and learning the scripting how can achieve the same with different ways.