As an example, the HTML in Listing A is not executing as planned. Basically, it verifies values that are entered in two text fields before the form is actually submitted.
The form is always submitted regardless of values entered, so we can use alert statements to inspect the contents of values during script execution. The script in Listing B uses alert statements to monitor variable values.
If you execute the script, it is clear the if statements always evaluate to true. Upon closer inspection, you will notice the assignment operation is being used (=) as opposed to equality (==). By making these two changes, the script will execute as expected.
This error is common, especially when developers are moving back-and-forth between languages like VB.NET and others that have different syntax. Here's a quick look at more common errors:
- Strings must be enclosed in quotes (single or double).
You may be able to debug browser-based applications via your favorite IDE. Visual Studio is one example that allows you to debug Internet Explorer applications via its debugging support. You must have debugging enabled on the Web server (IIS). Follow these steps to use it:
- Start the Web application in debug mode (Debug | Start).
- The application launches in a browser window. Return to the Visual Studio client. Select Debug | Window | Running Documents.
Another language to debug
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.
Miss a column?
Check out the Web Development Zone archive, and catch up on the most recent editions of Tony Patton's column.