I am trying to avoid passing the null
value returned by the server so that invalid date
isn't shown on front end. I am referring to the following code :
//var value_ = "2017-06-09 10:05:21.0"
var value_ = null;
if(moment(value_).isValid()){
alert(moment(value_).format('MM/DD/YYYY'));
}
else {
alert("Display Empty String:"+"");
}
So, passing empty string " "
works well from the UI point of view and I don't see invalid dates
for dates which have null
values. When I pass the empty string to the server" "
, I get an error similar to the one someone is facing here which is obvious because I am passing empty string:
parse a emty string into SimpleDateFormat
Is there a way to overcome this from UI point of view so that I don't see invalid date
option just like it's shown in this JSFiddle ?