A Sticky Form With Formatting and Input Validation
Introduction.
Since Wutka already has this example developed and I used it to learn more
about sticky forms, I will present it here. Basically, it is a
sticky input form that will
You should call this JSP page name_formatter.jsp. |
<html> <head> <title>A Sticky Form for Formatting Inputs</title> </head> <body bgcolor = "003344" text="cccccc"> <% String first_name = request.getParameter("txt_first_name"); if (first_name == null) first_name = ""; String last_name = request.getParameter("txt_last_name"); if (last_name == null) last_name = ""; String address = request.getParameter("txt_address"); if (address == null) address = ""; String city = request.getParameter("txt_city"); if (city == null) city = ""; String state = request.getParameter("txt_state"); if (state == null) state = ""; String zip = request.getParameter("txt_zip"); if (zip == null) zip = ""; String formatOption = request.getParameter("sel_format_option"); if (formatOption == null) formatOption = ""; // since some fields are required // set the default style for the required labels String firstNameRequiredColor = "blue"; String lastNameRequiredColor = "blue"; String zipRequiredColor = "blue"; String requiredNotifyColor = "red"; // checking to see if this form has been submitted if (request.getMethod( ).equals("POST")) {
} |
After copying this code and uploading it and accessing it on your web you should see something like the following after entering the initial inputs and purposely leaving some required entries blank. |
After pressing the Format! button you should see something like the following. |
After filling in the remaining required entries you should see something like the following. |
The code has a several aspects that need to be
discussed.
|