I need to do an email input and button, and if it is valid to open a successful registration pop-up with adding style to it, but if the email input is empty or invalid to open an error pop-up. I don't know why, but the If, Else statement doesn't work and when I press the button nothing happens
Here is my code input code in HTML
<input name="email" class="form-control" type="email" placeholder="Enter your email" required>
<button type="button" class="btn btn_100 3x" >Register</button>
<script>
var testEmail = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
if (testEmail.test(valueToTest))
{
$(document).ready(function(){
$(".3x").click(function(){
$(".3X").css("display", "block");
});});
}
else
{
$(document).ready(function(){
$(".3x").click(function(){
$(".2rr").css("display", "block");
});});
}
</script>