# A Detailed Guide to Native JavaScript Form Validation Methods and Properties, Including...

# A Detailed Guide to Native JavaScript Form Validation Methods and Properties, Including checkValidity() by zhangxinxu from https://www.zhangxinxu.com/wordpress/?p=8895 You’re welcome to share or aggregate this article, but please don’t republish it in full. Respect copyright—t...

Code: Dispatching a CustomEvent

const event = new CustomEvent('show', {
  detail: { message: payload, sentAt: new Date().toLocaleTimeString() }
});

window.dispatchEvent(event);
Result
Waiting for an event...

Code: Listening for the Event Payload

window.addEventListener('show', (event) => {
  render(event.detail.message, event.detail.sentAt);
});
Event log
No events yet.