I have the following code structure. I want to be able to capture the true/false value from swal function and return it to validate_empty_fields(). I know the following code only returns a promise object and swal only allows you to nest the true/false code within a then function. Is there a way to return the respective value when a user clicks the cancel or ok button.
function validate_empty_fields()
{
let x = document.forms["myform"]["title"].value;
let y = document.forms["myform"]["description"].value;
let z = document.forms["myform"]["image"].value;
if(x=="" && y=="" && z== "")
{
swal('warning','Atleast one of the fields must be filled');
return false;
}
else if(x=="" || y== "" || z== "" )
{
return swal({title: 'warning',
text: 'Empty fields will be pushed as such',
buttons:true});
}
}
</script>
<form action="addpages.php" name="myform" method="POST" onsubmit="return validate_empty_fields()" enctype="multipart/form-data">
//input fields for title,description and image
<button id="submit-btn" type="submit" >ADD PAGE</button>
</form>