I want to write a function in jQuery that when a user click on a checkbox a textfield-2 becomes enabeled and required and textfield-1 becomes disabled. if checkbox is not checked, the textfield-2 is disabled and not required and textfield-1 is enabeled.
So is like a toggle between these 2 textfield. the form is sth like this:
<form id="link" name="link" action="post">
<input type="checkbox" name="url_type" id="url_type" >
<input type="text" name="textfield1" id="textfield1">
<input type="text" name="textfield2" id="textfield2" disable="disable">
<input type="submit" name="send" value="send">
</form>
And the jQuery Code looks like this:
<script type="text/javascript">
$('#url_type').on('change',function(){
var checked=$('#url_type').is(':checked');
if(checked==true)
{
$('#textfield1').attr('disabled',true);
$('#textfield2').attr('disabled',false);
} else {
$('#textfield1').attr('disabled',false);
$('#textfield2').attr('disabled',true);
}
});
</script>
The problem i have is that at cakephp when i create a new link, if the checkbox is not selected works fine, but if i check the checkbox, ( meaning that textfield2 becomes enabled and textfield1 disabled ) it generate an error that looks like this:
The request has been black-holed Error: The requested address was not found on this server.
I donn't know where the conflict is or what is generating that error!