以下为引用的内容: <html> <head> <title>JS Test</title> <script type="text/javascript"> function MissingValueException (errMsg) { this.message = errMsg; this.name="MissingValueException"; } function doIt() { try { if (document.forms[0].fullName.value == '') { noNameException = new MissingValueException("First name is missing."); throw noNameException; } } catch(e) { if (e instanceofMissingValueException) { document.write(e.message + "<br>"); document.write("Please contact the administrator.<br><br>"); } else { document.write("An unexpected error has occurred.<br>"); document.write("Please contact the administrator.<br>"); document.write(e.message); } } finally { document.forms[0].submit(); } return 0; } </script></head><body> <form id="frmTest"> Name: <input id="fullName" name="fullName" type="text"><br> Address: <input id="contactNumber" name="contactNumber" type="text"><br> <input type="button" value="Submit" onclick="doIt();"> </form></body></html> |