mardi 17 septembre 2019

Problem with getting javascript answer after a subscription button

i've been working hours on the problem, but nothing. I explain : I'm doing a form with one field : a password form. When I submit it, I just want the javascript to tell the user if the password is the good one or if he has to try again. Here's my code (i'll tell you the problem just after it) :

var x = document.forms["CodeForm"]["email"].value;
if (x == "MAX") {
    $message._show('success', '✅ Code Correct !');
} else {
    $message._show('failure', '❌ Code Incorrect !');
}

As you see, the "succes" and "failure" parts are for my CSS class who tells the script the color of the text just after. Now, my problem is when I enter anything, the "if" part works and it says "Code Incorrect !" in red (as I want) but if I enter the good code just after, it says "Code Correct" but in red, and not in green as it is in the CSS class "success". When I enter the good code first (after reloading the page) then it's in green. So plz help me, if you don't understand I can be more precise. If you wanna try it, here's my website, and the good code is "MAX" : http://enigma-door.000webhostapp.com




Aucun commentaire:

Enregistrer un commentaire