const ticket = {
movie : document.getElementById("movie").value,
amount : document.getElementById("amount").value,
};
This is my object and I want to validate input. But I'm not sure how to change if-else statements to one switch case, since it has different statements.
PS: for learning purpose I need to use javaScript and not jQuery.
if(ticket.movie ===""){
document.getElementById("warningMovie").innerHTML = "need to choose a movie"
}else{
document.getElementById("warningMovie").innerHTML = "";
}
if(ticket.amount === ""){
document.getElementById("warningAmount").innerHTML = "need to choose amount"
}else{
document.getElementById("warningAmount").innerHTML = "";
}
Aucun commentaire:
Enregistrer un commentaire