By adding some new line escape characters or line breaks – \n, we can display multiples lines message in the alert box. It allows us to show a long message to users and also help people understand clearly.
It’s useful when display error message in registration forms or tell people what they need to do or what’s happening.
<script language="javascript"> alert("Hello," + "\n" + "This is a alert box" + "\n" + "... with multiple lines"); </script> |