I am creating a new Web site and want the forms checked by Javascript before the data are submitted to the server.
I am using the same Javascript code that I have used for this purpose, but for some strange reason the Javascript is NOT firing and instead the form is submitted to the server before client side Javascript checking is done.
For example click on “Sign Me Up” button without filling some form inputs, you should get Javascript alert messaage about forms that have not been filled yet, but that does not happen and instead the form is submitted to server!
Thanks for that tip.
I cannot believe that I missed that!
But that is what I hate about JS, that is one gets no Error message.
OTN, is there a plug-in to one of the Web browsers now that would
provide one with JS Error messages when the debug mode for JS is
truned on? So as developed we could see any JS Error messages when
we have this software (plug-in) On?
The web browser will generally give you good feedback on an error message, with the exception of IE which is known for obtuse js errors. Syntax errors like the one you had usually generate fairly obvious errors, but its up to the individual browser type to choose how to warn you.
I use a jslint plugin for my text editor which tells me about formatting/syntax issues before I deliver the code to the browser. You can also enable a javascript console on all modern browsers:
Chrome (ctrl+shift+i or ctrl+shift+j)
Firefox (install firebug addon, adds some nice stuff around the default FF console)
IE 8 + (f12)
Safari (Web developer tools in the preferences menu)
I’m pretty sure opera has one as well - it seems to move around every version update - in 11.11 you can tell errors to open the js console automatically by using ctrl+f12 -> advanced -> content -> javascript options.
Short story: almost every modern browser already has these tools available either by default on a vanilla installation or as an addon.
I created a simple Javascript Errors, that thus I would know of, and then tried the F12 function on chrome and it gives NO Error message about why the JS code is not firing properly!
No chrome doesn’t say that. I found the error when I copied you code, put it in netbeans, and said “Format code”. That’s when I saw (NetBeans doesn’t give an error) that the curly brackets didn’t match. Plus, NetBeans highlights the corresponding bracket when your cursor is on a bracket; also very handy