Forum Discussion

kevinkleint's avatar
kevinkleint
Contributor
7 years ago

Testing for Current Date in a Text Box

Hi! I'm trying to find a way to test for the current date in a text box (formatted as MM/DD/YYYY). Is there a way to do this using the front end? If not, what would the code look like using JScript?

 

Thanks!

 

Kevin Kleint

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    So, you're checking to see if the text box contains the current date, is that correct?

     

    Well, I'm assuming the text box has some sort of property like "text" or "wText" or something like that.  You know the date is formatted as MM/DD/YYYY so, this is what I propose.

    var currentDate = aqConvert.DateTimetoFormatStr(aqDateTime.Today(), '%m/%d/%Y');
    if (myTextBox.wText === currentDate) {
        Log.Message('They match');
    }
    else {
        Log.Error('The dates do not match');
    }

    Alternatively, if you're using KeywordTests, you COULD do a properyCheckpoint on that propery and set the value that you are checking to a code expression of 

     

    aqConvert.DateTimetoFormatStr(aqDateTime.Today(), '%m/%d/%Y')
    • kevinkleint's avatar
      kevinkleint
      Contributor

      Hi!

       

      I thought about it a little bit and figured it out. This was the code I used.  Thanks for your input though!

       

      function showPresentDate()
      
      {
      
      dt = new Date(); //Gets today's date right now (to the millisecond).
      
      month = dt.getMonth()+1;
      day = dt.getDate();
      year = dt.getFullYear();
      presentdate = month + '/' + day + '/' + year;
      
      aqObject.CheckProperty(Aliases.ceraexe0.dlgServices.EditReceived, "wText", cmpEqual, presentdate);
      
      }

       

       

      Kevin Kleint