I want to be able to define everything about the form field in one place, and not have some information in the database, some in HTML, some in JavaScript, some in ASP ...
Why do I have to worry about the possibility of change in four separate places (or more) when I want to change something in one field?
Ie, I do not want:
- declare a field in the database
- and duplicate some of this information in HTML somewhere
- and duplicate some additional information in some kind of javascript somewhere
- and duplicate some additional information in some ASP somewhere
Since I am a developer, I am ideally looking for a methodology, not a tool or S / W package. (I think!)
Currently , I am doing this by putting all the control information in the text area of the SQL extended property "Description". For example, the following SQL declaration will be shown in the required phone number field:
[home_phone] [varchar](15) NOT NULL
and I added the following controls to the extended description property:
["Home Phone"][phone_text][user_edit][required][allow_na][form_field_size_equals_size][default=""][group="home_address"][rollover="enter only: numbers, dash, parenthesis, space"][explanation="enter <strong>n/a</strong> if you don't have a home phone"]
In my current system, the following HTML is dynamically generated for the Home Phone field:
<div class="div-item" id="item-FORM:FIELD:TABLE_HOME:HOME_PHONE"> <div class="div-item-description" id="item_description-FORM:FIELD:TABLE_HOME:HOME_PHONE"> <span class="rollover-explanation" title="enter only: numbers, dash, parenthesis, space"> <label for="FORM:FIELD:TABLE_HOME:HOME_PHONE" id="item_label-FORM:FIELD:TABLE_HOME:HOME_PHONE"> Home Phone </label> </span> </div> <div class="div-item-stipulation" id="item_stipulation-FORM:FIELD:TABLE_HOME:HOME_PHONE"> <span class="stipulation-required" id="item_stipulation_span-FORM:FIELD:TABLE_HOME:HOME_PHONE" title="required" > * </span> </div> <div class="div-item-value" id="item_value-FORM:FIELD:TABLE_HOME:HOME_PHONE"> <div class="individual-forms"> <form class="individual-forms" id="FORM:TABLE_HOME:HOME_PHONE" name="FORM:TABLE_HOME:HOME_PHONE" action="" method="post" enctype="multipart/form-data" onsubmit="return(false);"> <div class="individual-forms-element"> <input class="" type="text" id="FORM:FIELD:TABLE_HOME:HOME_PHONE" name="FORM:FIELD:TABLE_HOME:HOME_PHONE" size="15" maxlength="15" value="" FORM_control="true" FORM_control_name="Home Phone" FORM_control_is_required="true" FORM_control_is_phone_text="true" > </div> </form> </div> </div> <span class="spanExplanation"> enter <strong>n/a</strong> if you don't have a home phone </span> </div>
which looks like this (in IE 7):

JavaScript-based client-side validation is controlled by **FORM_control**... parameters, which, when an error **FORM_control**... , generate explanations and highlight fields. (Unfortunately, custom parameters in HTML elements are not standards compliant.)
My main problem is that this method, using the Description field, has always been cumbersome to use and maintain. The Description property can only contain 255 characters, so I have a lot of abbreviations. As the system expands, the number of controls has also expanded significantly over the past ten or so. And my code for interpreting all these controls and their abbreviations is simply not good or effective. And, as I said, custom parameters in HTML elements do not work in FireFox.
I am currently in control (and want to continue to control):
- Field description (for example, "Home phone number")
- DB table name (for example, "home_address")
- DB field name (for example, "home_phone")
- Type and size of the database field
- DB allows null
- Grouping (for example, this particular field is part of all the Home fields).
- Mandatory / optional
- Read only (for system data)
- Size (submitted form field size)
- Type (e.g. text, number, alpha, selection, zip code, phone, address, name, date, etc.)
- Accepted input (not empty, only numeric, without spaces, phone number, reg exp, etc.)
- Extended explanation (for example, for phone # "enter n / a if you do not have a home phone")
- Explanation to collapse (for example, for phone # "enter only: numbers, dashes, brackets, space")
- Lines (for favorite lists - 1 = drop-down list)
- Rows / Columns (for text areas)
- Error message text
- Error indication (how to show which field contains an error, for example, a red background)
- Etc ...
And to be clear, I'm all for separating logic and design elements. I have a separate CSS file that is manually maintained (not part of the generation process).
My server environment is the classic (non .Net) ASP and SQL 2008. I am pretty good at HTML, CSS, JavaScript and ASP, and I like SQL.
I think what I want is some kind of JSON, XML, etc., which is the only source used to generate everything, for example:
- SQL script that actually creates SQL tables
- HTML (with CSS classes and client-side reviews / calls on the client side)
- ASP (server side validation)
My current method that does this is dynamic (not compiled) and rather slow, so I'm probably looking for some kind of “compiler” that generates this stuff once. And I really only have classic ASP, JavaScript, or SQL as the available languages for this “compiler”.
And although I think I can create this system myself, I hope that other, better developers have already come up with something similar.
Suppose this should scale for at least a few fields. (FYI, my current form has too many fields on one page, but I solve this problem separately.)
Thanks for any help!