I have a form with email and password validation. When password is wrong the box password has to be red to show that something go wrong, i do that adding a "vermei" class.
I have to do this in PHP, already attempted:
$dom=new DOMDocument;
$dom->loadHTML($html);
$input=$dom->getElementById('password');
foreach($input as $pd){
$pd->setAttribute('class', $pd->getAttribute('class').' vermei');
}
$html = $dom->saveHTML(); // return 'variable $html not found'
and
echo '<script>
alert("Password Incorrect!");
history.go(-1); //work until this part, the code below do not run.
//I did this go back cuz when form is submitted, go to config.php, and
// this code back to sign in page
var password = document.getElementById("password");
document.getElementById("password").focus();
password.classList.add("vermei");
</script>';
Someone can help me with adding a "vermei" class in Password input?
getElementByIdjust returns a single element, not a list. You don't need the loop.vermeiclass to html, and nothing happen