I’m new to Wix and coding. I’ve created a Wix members page and would like to add more pages but mimic the buttons (Discard and Update Info) that’s used in the Account page.
I’m using a dataset and repeater in the new page. I was able to build the input field to show the text. I also have the Discard and Update button working. The default is to disable the buttons. oninput, the buttons get enabled.
What I’d like is for the buttons to re-disable if the changes were deleted (i.e. the text matches the dataset value).
This is the code I’m using. The check enables the button if I add text to the input box, but if I delete the added text (i.e. no change), the button remains enabled. I would like it to re-disable. Any help would be great. Thanks.
let previousValue = “”;
export function input1_input(event) {
// This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com
// Add your code for this event here:
if (event.target.value === “”) {
$w(‘#button3’).disable();
$w(‘#button5’).disable();
} else if (event.target.value !== previousValue) {
$w(‘#button3’).enable();
$w(‘#button5’).enable();
}
previousValue = event.target.value;
}
I’ve also tried this, per ChatGPT
let previousValue = ‘’;
export function input1_input(event) {
const inputValue = $w(“#input1”).value;
const datasetValue = $w(“#dataset1”).getCurrentItem().textfield;
if (inputValue === datasetValue) {
$w(“#button3”).disable();
$w(“#button5”).disable();
} else {
$w(“#button3”).enable();
$w(“#button5”).enable();
}
}