Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool How to pass auto numbered objects in a function

    Hi All

    I have a .jsp page which pulls up multiple workshops data for editing.

    The workshop array is looped and each description, presenter, seats textbox is also looped like

    txtPresenter1
    txtDesc1
    txtSeats1

    txtPresenter2
    ...

    i have a 3rd party validation script
    that takes in the format

    form.addValidation("txtPresenter", required)
    form.addValidation("txtDesc", required)


    Now is there some way i can loop and construct a validation function for each set of text boxes

    or better i am thinking i should have 1 global validation function for each presenter, description and so on but how to implement it ?

    Many thanks
    R

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    i don't quite understood your problem... You wanna use validation functions for group of fields? In this case nest them in divs and loop the div's childs

    function validate01(){
    var fields=document.getElementById('d01').getElementsByTagName('input');
    for(var i=0;i<fields.length;i++){
    if(...negative codition...){
    alert('message');
    fields[i].focus();
    return false;
    }
    }
    }
    function validate02(){
    var fields=document.getElementById('d02').getElementsByTagName('input');
    for(var i=0;i<fields.length;i++){
    if(...negative codition...){
    alert('message');
    fields[i].focus();
    return false;
    }
    }
    }
    ..
    function validate(){
    validate01();
    validate02();
    }
    ...
    ...
    <form onsubmit ="return validate()">
    <div id="d01">
    ...group of fields here
    </div>
    <div id="d01">
    ....group of fields here
    </div>
    <input type="sumbit" value="submit">
    </forms>
    ...
    ...
    or something like that
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •