OK. assuming the posted code was not complete. There are couple of thing that I see.
1. There something wrong with the regular expression, the backslash need to be escaped (adding \)
Regex Tutorial - Literal Characters and Special Characters[
^] . So it should look like
[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
2. I think the last else statement is redundant, because it overwrite the isValid indicator in the scenario where both password are empty, it will return true.
3. Here how your code look like after the minor modification.
CP_validateregistrati - JSFiddle[
^]