The following code is not returning false
. When the reg2
field is empty and the reg1
field is selected, the function should return false
, but this is not happening.
Here is the code for review: Script that releases the div with input.
$j("#reg_2").hide();
$j("#reg1").click(function() {
if($j("#reg1").is(':checked')){
$j("#reg_2").show();
} else {
$j("#reg_2").hide();
}
});
Part of HTML
<div class="wrapper">
<input type = "checkbox" name ="reg1" id ="reg1" />
</div>
<div id="reg_2" class="wrapper">
<span>Nº do registro:</span>
<input id="reg2" name="reg2" type="text" class="input" />
</div>
Script evaluating the reg2 condition:
} else if ($j("#reg1").is(':checked') && $j("reg2").val() == "") {
$j("#reg2").css({
"border": '1px solid #ff0000'
});
alert("É necessário informar o Registro no MAPA").focus();
$j("#reg2").keypress(function() {
$j("#reg2").css('style', '');
});
return false;
}
#reg1
is a checkbox and #reg2
is of type input text, if the reg2 field is empty and reg1 is checked, the function should issue the alert and return false, but it is not happening.