There’s a button to get to the next page. Is it possible to make this button only available when the input on the current slide is valid? As an example: In this multistage form here , “First Name” is required. I want to achieve, that the button “Save & Continue” only works, if “First Name” is valid, so somebody typed his name in that field.
Same if somebody typed text into a number-field. This is not valid, so the button should not be available so that the user can’t jump to the next slide.
The article Validating User Input with Code will help you with this. You can also look at the appropriate validation properties and functions that are available for many components. Look at the valid property of TextInput as an example.
Wix code doesn’t support custom validation on multistage form. Have to ditch multistage form and put 100 input elements on single page for it to work. Site looks so displeasing
what I did (and what I see as a good solution) is the following. You can disable the button for 2 seconds and reenable it when the input in the fields is not valid. Here input1 has to be filled out (not empty) and input2 needs to be bigger than 300.
Hey I have a sort of similar problem with my user input validation. Every user input for my quiz is being marked “incorrect” no matter what. The answers are generated from a database, and into a hidden text box that appears after the user input is submitted.
I need code to check the user input against the text box. This seems simple but I cant find anything to help.
Here is my code atm:
export function button1_click() {
$w(“#input1”).onCustomValidation((value => {
if ($w(“#input1”).value !== $w(“#answerC”)){
$w(“#incorrect”).show();
$w(“#answerC”).show();
$w(“#correct”).hide();
}
else {
$w(“#correct”).show();
$w(“#answerC”).show();
$w(“#incorrect”).hide();
}
Using wix codes dynamic pages and databases will keep me from having to program 1200+ iterations for each type of question one at a time. I really need this to work and it seems like it should be a simple fix.
If you are able to help I would be eternally grateful
Hello, I’m trying to do exactly the same thing as the OP, I have managed to get my button to work if the 2 inputs have a value above 50. but should the button be clicked before values are selected, it disables and doesn’t come back on. my code is below which i just copied from above.
i’m very new to this, it’s the last 4 lines that I don’t understand, what does the #text120 relate to? and the 2000.
thanks for any help in advance
export function button3_click(event, $w, reject) { if ($w(‘#dropdown1’).value > 50 && $w(‘#dropdown2’).value > 25 ){
$w(‘#slideshow1’).changeSlide(1);
} else {
$w(‘#button3’).disable()
@connectshubham Is there anyway to add a collapse function to text120? I’m trying to validate all inputs but seems like I could only add on else function in there.
export function button4_click(event) { let text101 = ‘’; if ($w(‘#input4’).valid && $w(‘#input5’).valid && $w(‘#input6’).valid && $w(‘#input8’).valid && $w(‘#input10’).valid && $w(‘#input9’).valid && $w(‘#dropdown3’).valid && $w(‘#input13’).valid && $w(‘#input12’).valid){
showbutton2();
} else { if (!$w(‘#input4’).valid);
text101 += “Please enter first name\n”; if (!$w(‘#input5’).valid);
text101 += “Please enter last name\n”; if (!$w(‘#input6’).valid);
text101 += “Please enter company name\n”; if (!$w(‘#input8’).valid);
text101 += “Please enter address\n”; if (!$w(‘#input10’).valid);
text101 += “Please enter suburb\n”; if (!$w(‘#input9’).valid);
text101 += “Please enter postcode\n”; if (!$w(‘#dropdown3’).valid);
text101 += “Please select state\n”; if (!$w(‘#input13’).valid);
text101 += “Please enter an email address\n”; if (!$w(‘#input12’).valid);
text101 += “Please enter a phone number\n”;
@I.hottelmann Hi, just wondering if its possible to add another else function that has a collapse function into the code so I won’t have to create 36 textboxes.