The issue appears to be here (unless it was a typo):
if (isValid = true)
You're assigning true
to isValid
, so the condition in the if
statement is always true.
The proper way to do comparison of primitive values is by using two equals signs:
if (isValid == true)
However, for booleans, this is redundant. The best way to test if a boolean value is true/false is simply to use the boolean variable itself:
if (isValid)