[Javascript] Checkbox validation
Cutter (JS)
java.script at seacrets.com
Wed Jan 4 14:02:20 CST 2006
Yeah, I do need the count later on, but Diego's answer was exactly what
I needed (TYVM)
Cutter
Shawn Milo wrote:
> Kind of a weird thing. I think maybe you could just simplify it and
> use a boolean. That should guarantee success, unless you need the
> actual count later in the script.
>
> Milo
>
> On 1/4/06, *Cutter (JS)* <java.script at seacrets.com
> <mailto:java.script at seacrets.com>> wrote:
>
> OK, strange one here. Writing some custom form validation scripting on
> some dynamically created forms. Currently I have a form where a
> user can
> delete files from the system. They have the ability to check a
> checkbox
> (name='deletefiles' value=[filename]) for each file they wish to
> remove.
> When the form is submitted a formValidate() function is called and, in
> this instance, an isRequiredCheckbox(fldObj) function is called.
> This is
> to verify that at least one selection has been made. This works
> great if
> there are multiple files (which, in turn, means more than one
> checkbox),
> but doesn't work properly when there is only one file (and one
> checkbox)? Below is the basic code affected. Any ideas would be
> appreciated.
>
> Cutter
>
> //first of all you must know that the fldObj object has a property
> 'FieldName' that is the form field object
> // as in fldObj.FieldName = document.forms.myform.mycheckboxfield;
> function isRequiredCheckbox(fldObj){
> valCheck = 0;
> selChoices = -1;
> for (counter = 0; counter < fldObj.FieldName.length; counter++){
> if (fldObj.FieldName[counter].checked) {
> selChoices = selChoices + 1;
> }
> }
> if (selChoices < 0){
> alert('You have not made any selections.');
> } else {
> valCheck = 1;
> }
> return valCheck;
> }
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu <mailto:Javascript at LaTech.edu>
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
More information about the Javascript
mailing list