Hello veil community, I am new to using this work tool.
I have a problem, I hope you can help me, I am saving data in my form using wix-Data,, and performing validations.
At the time of saving the data is sent to my database, I was able to disappear the input data but the validations skip, how to make them disappear too ..
THIS IS MY CODE
SAVE DATA FUNCTION
export function submitBtn(event) {
let cliente = {
“nombre”: $w(“#nombreAlumno”).value,
“correoelectronico”: $w(“#correoElectronico”).value,
“anioescolar”: $w(“#anioEscolar”).value,
};
console.log(‘Datos del estudiante’ + JSON.stringify(cliente));
if ($w(‘#nombreAlumno’).valid && $w(‘#correoElectronico’).valid && $w(‘#anioEscolar’).valid) {
wixData.insert(‘prueba2’, cliente)
.then((results) => {
console.log(results);
let clienteGuardar = results;
// console.log('Cliente en la base de DB' + JSON.stringify(clienteGuardar));
}).catch((err) => {
let mensajeError = err;
console.log(mensajeError);
})
}
}
VALIDATE FUNCITION
export function validation() {
//Validacion del campo nombre
let nombreAlumno = $w(“#nombreAlumno”);
nombreAlumno.onCustomValidation((value, reject) => {
let nombre = $w(“#nombreAlumno”).required;
if (value == "" || value == null) {
// validationMessage += "Por favor ingresa tu nombre";
reject('Por favor ingresa tu nombre')
if (nombreAlumno.valid) {
if (nombreAlumno.value) {
// validationMessage += 'Ingresa tu nombre';
reject('Por favor ingresa tu nombre');
}
}
}
if (value == nombre) {
reject('Campo llenado correctamente');
$w("#nombreAlumno").value = '';
}
});
//Validacion de correo electronico
$w(“#correoElectronico”).onCustomValidation((value, reject) => {
let correo = $w(“#correoElectronico”).required;
if (value == “”) {
reject(“El campo correo esta vacio”);
// let botonPaypal = $w(“#pagarPaypal”).hide();
} else {
let botonPaypal = $w(“#pagarPaypal”).show();
if (value == correo) {
reject("El campo correo es correcto");
$w("#correoElectronico").value = '';
}
}
});
}