---
title: "Comment by Eric Sacramento on \"Easy Date Handling in JavaScript with apex.date\" | Hashnode"
description: "Hi Jon, I think in example 2 the code apex .message .clearErrors (); should be executed outside the if condition. Because if the user fixes the error, the messa"
url: "https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/62fe8a0cf1a220fcdbb6516f"
---

[Discussion](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d)

Comment [Easy Date Handling in JavaScript with apex.date](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d)

[Eric Sacramento](https://hashnode.com/@ericsacramento)

[Aug 18, 2022](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/62fe8a0cf1a220fcdbb6516f)

Hi Jon,

I think in example 2 the code

```
apex.message.clearErrors();
```

should be executed outside the if condition. Because if the user fixes the error, the message will go away.

Thank you for your time.

Eric

[Jon Dixon](https://hashnode.com/@orclapex)

[Aug 19, 2022](https://hashnode.com/posts/apex-date-js-api/62fe333daa9d01fcb62eff2d/comment/62fe8a0cf1a220fcdbb6516f#reply-62ff8dd267b2030c206c1ea4)

Hi Eric, You are quite right, I have fixed it. Thanks for letting me know.
