cancel
Showing results for 
Search instead for 
Did you mean: 

How to validate the value of a sap.ui.commons.DatePicker?

Former Member
0 Kudos

Hello,

i'm using a sap.ui.commons datepicker. I need to make sure, that the user enters a valid date. Afterwards i create a timestamp using the entered date.

The function getYyyymmdd() returns the last valid date when entering wrong values like "abcd" into the textfield. I need to find a way to tell the user to input valid dates only. I cannot use getValue() as this simply returns the string "abcd", but i have to check this against the locale settings of the user.

Is there a way to check against the locale settings? Does the DatePicker have a function/event to do this automatically?

Thanks.

Best regards

Alexander

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Use the change event and validate the date. check this thread for reference: http://scn.sap.com/message/15432225#15432225

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Thanks a lot. Thats what i needed

Answers (1)

Answers (1)

former_member232384
Participant
0 Kudos

new sap.ui.commons.DatePicker({change:function(oEvent){

  if(oEvent.getParameter("invalidValue")){

      alert("Invalid value");

  };

}