Page 1 of 1
Form Validation Help
Posted: Tue Aug 17, 2021 11:04 am
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?
Re: Form Validation Help
Posted: Tue Aug 17, 2021 11:51 am
by Pablo
There is no standard option for this, this will require a custom script.
Re: Form Validation Help
Posted: Tue Aug 17, 2021 11:57 am
by BaconFries
See the following url. Note provided for information only no help implementing.
https://stackoverflow.com/questions/457 ... -they-have
Re: Form Validation Help
Posted: Tue Aug 17, 2021 12:41 pm
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?
Re: Form Validation Help
Posted: Tue Aug 17, 2021 1:13 pm
by Pablo
A form can only have one success page. So, using a different submit button will not work.
Re: Form Validation Help
Posted: Tue Aug 17, 2021 7:21 pm
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);
}
Re: Form Validation Help
Posted: Tue Aug 17, 2021 8:03 pm
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.
Re: Form Validation Help
Posted: Tue Aug 17, 2021 8:09 pm
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?
Re: Form Validation Help
Posted: Wed Aug 18, 2021 6:19 am
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.