This document describes how to add validation for custom fields on your
patron question form. Validation in this context refers to ensuring that
the user enters a value in a field before he or she can submit the question
to QuestionPoint. We will do our best to provide support on this procedure
as written. The procedure assumes a certain level of familiarity with
the appropriate Web technologies, and our support staff is not equipped
to provide instruction in HTML, JavaScript, or Web design
You can also add more sophisticated validation for any field, but this
validation goes beyond the scope of this procedure and the support we
can provide. For examples, see the additional validation provided in question
form Example #2 and Example
#3.
Go to the section of the file that contains your new fields.
3
To indicate that a field is required, change the field's screen
label in a way consistent with your question form's design, such
as preceding the field's label with an asterisk.
Example:
<! -- You can insert
added fields here -- >
<! - Added field entry -- >
<tr>
<th width="30%">
<label for="field1" accesskey="P">*Phone:</label>
</th>
<td width="70%">
<input type="hidden" name="label1"
value="Phone">
<input type="TEXT" name="field1"
id="field1"maxlength=255 size=50>
</td>
</tr>
4
Find the name of the field that you want to make required:
Open the question form in a Web browser. Leave all required
fields blank (including E-mail Address and Question) and click the
button for submitting a question. The message that appears should
indicate that you left the E-mail Address, Question, and the field
you just made required blank.
9
Back up your customized form with a new name. This preserves
the changes you've made so far and allows you to start over from this
point if necessary.
10
Repeat steps 3-9 for
every other custom field that you want to make required.
Copy and paste the lines in the text box below to the form:
Click the Highlight All button above the box.
With the code highlighted, right-click in the box..
Select Copy from the context menu.
Position the cursor in the form after the section shown in step
2 and select paste. You can paste by pressing Control-V,
selecting Edit -> Paste from your text editor's menu,
or clicking your right (secondary) mouse button and selecting
Paste from the context menu that pops up.
4
Replace fieldX with the field's name and labelX with the field's
label.
Copy and paste the lines in the text box below to the form:
Click the Highlight All button above the box.
With the code highlighted, right-click in the box..
Select Copy from the context menu.
Position the cursor in the form after the section shown in step
1 and select paste. You can paste by pressing Control-V,
selecting Edit -> Paste from your text editor's menu,
or clicking your right (secondary) mouse button and selecting
Paste from the context menu that pops up.
3
Replace fieldX with the field's name and labelX with the field's
label.
Example:
if (form.>field3.selectedIndex
== 0) {
if (msg.length >0)
msg+= ', ';
msg += 'Reason for research';
}
Copy and paste the lines in the text box below to the form:
Click the Highlight All button above the box.
With the code highlighted, right-click in the box..
Select Copy from the context menu.
Position the cursor in the form after the section shown in step
1 and paste the code. You can paste by pressing Control-V,
selecting Edit -> Paste from your text editor's menu,
or clicking your right (secondary) mouse button and selecting
Paste from the context menu that pops up.
3
Replace fieldX with the field's name and labelX with the field's
label.
Example:
for (i=0, n=form.field3.length;
i<n; i++) {
if (form.>field3[i]Checked)
{
var checkvalue = form.field3[i]Value;
break;
}
}
if (!(checkvalue)) {
if (msg.length >0)
msg+= ', ';
msg += 'Status';
}