How can I simplify this functioning JQuery validation process:
class UserEdit {
addUser(uobj) {
if(uobj.adduser == "" && uobj.addfullname == "" && uobj.addemail == "" && uobj.addlevel == "")
{
$('#adduserError').show();
$('#addfullnameError').show();
$('#addemailError').show();
$('#adduserlevelError').show();
return false;
}
if(uobj.adduser == "")
{
$('#adduserError').show();
return false;
}
if(uobj.addfullname == "")
{
$('#addfullnameError').show();
return false;
}
if(uobj.addemail == "" || (uobj.addemail.indexOf("@",0)) == -1 || (uobj.addemail.indexOf(".",0)) == -1 || uobj.addemail.length < 6)
{
$('#addemailError').show();
return false;
}
else
{
$('#loadingDiv').show();
$.post('process/editUser.php', {uobj:uobj}, function(data)
{
var modal = "#addUserModal";
$('#loadingDiv').hide();
dataCheck(data, modal);
});
}
}
}
All of the above works as it should. I just know there must be a way to simplify it.
Note (because I believe someone will ask): I use the dataCheck function to check the data returned from the PHP process, and then close the modal if the process was successful. There are a couple of other modules within the class that use the same dataCheck function. That was my initial attempt to at least simplify how to handle the return data in each module.
Now I want to try to simply the code above. Any help is appreciated.