Skip navigation
Currently Being Moderated

Validation required fields question

Apr 18, 2012 9:55 AM

I have a fillable form which I have a few required fields set.

 

 

However there is a main question are you an existing customer yes (tick box) or

are you a new customer (tick box)

 

 

then there are fields for each such as name, address, email etc

 

 

is there a way to only make required fields relevant if the person selects existing customer then the required fields for new customers can be ignored and vice versa.

 

 

Currently if the person selects tick box existing customer then unless they fill out the required fields under the new customer section they cannot submit the form.

 
Replies
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Apr 18, 2012 10:31 AM   in reply to VickiTuch

    You can use JavaScript to set the required property of the fields to true when the Yes check box is selected, and false otherwise. If you tell us what the field names are and the export value of the Yes check box is, we can suggest the specific code you cna use. It would be easiest if you used a hierarchical naming convention for the group of fields. For example, give each a prefix of "req1.' So the field names are: "req1.name", "req1.address", "req1.email", etc. This makes it possible to change the required property of the fields in the group with a single line of code:

     

    // Set all req1 fields to required

    getField("req1").required = true;

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 20, 2012 12:19 PM   in reply to George Johnson

    I want to add that if this radio buttonis already set to required then all this happens:

     

    if(event.target.value ==(1)) {

    // selected - show radio buttons

    this.getField('NotPresent1').display = display.hidden; // show radio button

     

    } else {

     

    // deselected show hide the radio buttons and reset the field

    this.getField('NotPresent1').display = display.visible; // hide radio button

    this.resetForm(['NotPresent1']); // clear radio button

    }

     

    // Set all S1 fields to required

    getField("S1").required = true;

     

    if(event.target.value ==(1)) {

    // selected - show radio buttons

    this.getField('Normal1').display = display.hidden; // show radio button

     

    } else {

     

    // deselected show hide the radio buttons and reset the field

    this.getField('Normal1').display = display.visible; // hide radio button

    this.resetForm(['Normal1']); // clear radio button

    }

     

    // Set all S1 fields to required

    getField("S1").required = false;

     

     

    And then to remove the requiredness of the radio button.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 20, 2012 12:23 PM   in reply to yeungyam

    changed my question above

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points