Form Validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sanju

    Form Validation

    Dear All,

    i have 10 textboxes on a form, I require the following validation

    1) if i fill the textbox in between(say 5th), then all textboxes
    before that should be mandatory,ie Textboxes(1,2,3 ,4) should be
    mandatory and rest of the textboxes should not be mandatory.

    Kindly help me out..

    Thanks in advance..
    Regards,
    Sanjay

  • Erwin Moller

    #2
    Re: Form Validation

    sanju schreef:
    Dear All,
    >
    i have 10 textboxes on a form, I require the following validation
    >
    1) if i fill the textbox in between(say 5th), then all textboxes
    before that should be mandatory,ie Textboxes(1,2,3 ,4) should be
    mandatory and rest of the textboxes should not be mandatory.
    >
    Kindly help me out..
    Well, what did you try so far?

    You should make a validationrouti ne that checks excactly that.
    What is the problem?
    Don't you know how to get the content of a textarea?
    Don't you know how to implement the logic to check the former X
    textelements for emptiness?
    Please state your problem clearer. :-)

    Erwin Moller
    >
    Thanks in advance..
    Regards,
    Sanjay
    >

    Comment

    • sanju

      #3
      Re: Form Validation

      On Apr 7, 1:50 pm, Erwin Moller
      <Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
      sanju schreef:
      >
      Dear All,
      >
      i have 10 textboxes on a form, I require the following validation
      >
      1) if i fill the textbox in between(say 5th), then all textboxes
      before that should be mandatory,ie Textboxes(1,2,3 ,4) should be
      mandatory and rest of the textboxes should not be mandatory.
      >
      Kindly help me out..
      >
      Well, what did you try so far?
      >
      You should make a validationrouti ne that checks excactly that.
      What is the problem?
      Don't you know how to get the content of a textarea?
      Don't you know how to implement the logic to check the former X
      textelements for emptiness?
      Please state your problem clearer. :-)
      >
      Erwin Moller
      >
      >
      >
      >
      >
      Thanks in advance..
      Regards,
      Sanjay- Hide quoted text -
      >
      - Show quoted text -

      Actually i dont know how to implement the logic to check the former
      X..
      Please help

      Thanks,
      sanjay

      Comment

      • SAM

        #4
        Re: Form Validation

        sanju a écrit :
        Dear All,
        >
        i have 10 textboxes on a form, I require the following validation
        >
        1) if i fill the textbox in between(say 5th), then all textboxes
        before that should be mandatory,ie Textboxes(1,2,3 ,4) should be
        mandatory and rest of the textboxes should not be mandatory.

        "should be" or "have to be" ?

        Have to be :

        function validate(myForm ) {
        var Cl = [];
        for(var i=0, L=myForm.length ; i++)
        if(myForm[i].type= 'text') Cl[Cl.length] = myForm[i];
        if(Cl.length==1 0 && Cl[4].value!='') {
        for(var i=0; i<5; i++)
        if(Cl[i].value == '') {
        alert('textfiel d : '+Cl[i].name+\nis empty !');
        Cl[i].focus();
        return false;
        }
        for(var i=5; i<Cl.length; i++) Cl[i].value=='';
        }
        else {
        for(var i=5; i<Cl.length; i++)
        if(Cl[i].value == '') {
        alert('textfiel d : '+Cl[i].name+\nis empty !');
        Cl[i].focus();
        return false;
        }
        for(var i=0; i<5; i++) Cl[i].value=='';
        }
        return true;
        }

        <form onsubmit="retur n validate(this); " blah >

        --
        sm

        Comment

        Working...