Form Validation Help

Issues related to forms.
Post Reply
Nomad Soul
 
 
Posts: 33
Joined: Wed Mar 07, 2012 10:17 pm

Form Validation Help

Post by Nomad Soul »

Hi

I have a regular WB16 form in my site.

I need to try and do a validation when pressing the submit button to check the value on a combo box.

If the combo box value is 1 the user should be directed to the normal success page. If the value is 2 they should be directed to a different page.

Is this possible or is there another way I can achieve this validation?
User avatar
Pablo
 
Posts: 21580
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Form Validation Help

Post by Pablo »

There is no standard option for this, this will require a custom script.
User avatar
BaconFries
 
 
Posts: 5328
Joined: Thu Aug 16, 2007 7:32 pm

Re: Form Validation Help

Post by BaconFries »

See the following url. Note provided for information only no help implementing.
https://stackoverflow.com/questions/457 ... -they-have
Nomad Soul
 
 
Posts: 33
Joined: Wed Mar 07, 2012 10:17 pm

Re: Form Validation Help

Post by Nomad Soul »

Thanks Both

I think i might have found a solution.

If the combo box value is 1 the page will be normal but if the combo box value is changed to 2 i will hide the normal submit button and show a 2nd submit button which goes to a different success page.

Will this work?
User avatar
Pablo
 
Posts: 21580
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Form Validation Help

Post by Pablo »

A form can only have one success page. So, using a different submit button will not work.
Nomad Soul
 
 
Posts: 33
Joined: Wed Mar 07, 2012 10:17 pm

Re: Form Validation Help

Post by Nomad Soul »

I'm trying to implement the JS code from this link:
https://stackoverflow.com/questions/457 ... -they-have

Where do I put this code in my WB16 page?

Code: Select all

redirectPage() {
  // Gets value of dropdown
  var selectedOption = $("#sponsor option:selected").val();

  // Picks correct url to go to
  var url;
  switch(selectedOption) {
    case "mark":
      url = "your link #1 here";
      break;
    case "markus":
      url = "your link #2 here";
      break;
    default:
      url = "";
      break;
  }

  // Changes current page and keeps back history
  window.location.assign(url);
}
User avatar
BaconFries
 
 
Posts: 5328
Joined: Thu Aug 16, 2007 7:32 pm

Re: Form Validation Help

Post by BaconFries »

BaconFries wrote: Tue Aug 17, 2021 11:57 am Note provided for information only no help implementing.
See the above. You will also need to modify to suit your own needs so a understanding of javascript or jQuery is needed.
Nomad Soul
 
 
Posts: 33
Joined: Wed Mar 07, 2012 10:17 pm

Re: Form Validation Help

Post by Nomad Soul »

Thanks BaconFries

I understand what needs to be changed in the code to suit my page. I have done this already.

I just don't know where to put the code. Can this be added in a HTML object or does it need to go in the submit button object HTML and which tag should it go after or before?
User avatar
Pablo
 
Posts: 21580
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Form Validation Help

Post by Pablo »

I just don't know where to put the code.
Normally, scripts are place between the head tags.
which tag should it go after or before?
You should add <script></script> tags around the code.
Post Reply