For "enquiring" minds, here's what I've discovered.
This VBScript REQUIRED FIELD validation logic works CLIENT SIDE when checking an HTML INPUT field or DROPDOWN list with SINGLE VALUE SELECTION:
if Document.formname.fieldname.Value = "" then
msgbox("Required field missing")
end if
Of course, this just checks to see that a value was entered or selected. More sophisticated chacking against the value provided could be performed, as well. Additionally, it needs mentioning that when working with a drop down list, it's necessary to define a default SELECTED value of "emptystring" or the list will default to the first value in the list and will never fail the REQUIRED field test above. I'm still not sure how to deal with multiple selections in a dropdown list, if that's even possible using the HTML drop down list.
For RADIO controls and CHECKBOXes:
For intPosIdx = 0 To Document.formname.fieldname.length - 1
If Document.formname.fieldname(intPosIdx).checked Then
blnSelFd = "Y"
Exit for
end if
Next
if blnSelFd = "N" then
msgbox("Required field missing")
end if
In the example above, it's necessary to loop through all the potential values to see if any are checked, setting a variable if they are. After, I check the variable tyo see whether a selection was made. While it works with both RADIO controls and CHECK BOXes, this logic is obviously not concerned with whether single or multiple selections have been made. More sophisticated logic could be added, of course.
Thanks again to Phil for showing me how to do this!
|