Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to validate date in an application should not accept less than future date.
#1
Not Solved
Hi,

Recently i have been asked a question in an interview where,

I have to validate that the application should not accept the date less that the current date. hoe to write the VB script code for this?

The condition is application does not keep tracks of the date, but when i am entering the date it in a field and submitting the record it should not submit the record if the date is less than T+1. (T=current date).


Helps are much appreciated.

Thanks.
Reply
#2
Not Solved
Hope the below code works out

'I have to validate that the application should not accept the date less that the current date. hoe to write the VB script code for this?
Code:
inputdate = cdate(Inputbox("Enter Date"))   '10/8/2014
'msgbox inputdate 'displays user entered date
'msgbox date 'displays current date
If inputdate = date or inputdate > date then
'Browser("Browser").Page("Page").Frame("DatePicker").Set inputdate
msgbox "valid date "& inputdate
Else
msgbox "Date Should not be earlier than current date"
end if

'The condition is application does not keep tracks of the date, but when i am entering the date it in a field and submitting the record it should not submit 'the record if the date is less than T+1. (T=current date).
Code:
inputdate = cdate(Inputbox("Enter Date"))   '10/8/2014
'msgbox inputdate 'displays user entered date
'msgbox dateadd("d",1,date) 'displays current date + 1 day
If inputdate = dateadd("d",1,date) then
'Browser("Browser").Page("Page").Frame("DatePicker").Set inputdate
msgbox "valid date "& inputdate
Else
msgbox "Enter a valid date Eg. Current Date" & "(" & Date & ")" & "+1 Day " & "i.e.,"& dateadd("d",1,date)
end if
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Click on calender on specific date. venkatesh9032 1 3,719 12-02-2015, 07:30 PM
Last Post: nistalaramesh
  How to validate a format of an alphanumeric string PrateepKaraval 2 5,754 11-08-2014, 10:26 AM
Last Post: vinod123
  Date Picker Issue - Unable to select date link dynamically rajkumarsm 1 4,938 09-20-2014, 09:31 AM
Last Post: rajkumarsm
  How to validate tool tip in a web page? qtplearner88 3 4,134 04-24-2013, 05:19 PM
Last Post: nucleation
  How to sort different dates in and get the Max date from those nilanjans 2 5,337 09-07-2012, 07:35 AM
Last Post: vIns

Forum Jump:


Users browsing this thread: 1 Guest(s)