Question

I have a javascript function which is called onclick of a button. It is working fine in chrome and firefox. It basically places some validation checks, so that in case of incomplete information form is not submitted to the server.

My question is that if in some browser the javascript function has some syntax errors, how can I ignore the errors, so that validation function is bypassed, after all validation function is just to reduce invalid form submits and checks are also placed on the server.

Was it helpful?

Solution

Its very unlikely (if not impossible), that you write some ECMAscript code which works fine on some engines and throws syntax errors on others. Unless you're dealing with something like IE4 or real old Netscape browsers.

However, you can of course always wrap your code into try..catch blocks, like

try {
   // beautiful javascript code
} catch( ex ) {
   alert(ex.message);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top