Click to See Complete Forum and Search --> : How to Get dynamic Blur on a text field?
said_fox
01-03-2003, 07:02 PM
Suppose this
<input type="text" value="don't change me" onfocus="this.blur()">
<input type="checkbox" name="sign" value="yes">
I want when checking this box, the blur on the text field will be disabled and the user can enter data inside it and vice versa.
Also suppose the page contains several text fields and I want make a checkbox for each one to do the action described above
Please Help!!:confused:
said_fox
01-03-2003, 07:52 PM
Thanks Dave,
But please Explain more clearly, I'm still new to this stuff
khalidali63
01-03-2003, 08:00 PM
try this code sinppet below,
just follow the naming convention used to name chackboxes as cb+any number and corresponding text field as t+number
Khalid
<html>
<head>
<title>Untitled</title>
<script>
function blurIt(obj){
ob = eval('document.frm.'+obj.name);
ob.disabled = true;
var tn = ob.name.toString();
var dig = tn.charAt(tn.length-1);
if(!isNaN(dig)){
tObj = eval('document.frm.cb'+dig);
tObj.checked = false;
}
}
function processForm(obj){
var ob = (obj.name).toString();
var dig = ob.charAt(ob.length-1);
if(!isNaN(dig)){
tObj = eval('document.frm.t'+dig);
tObj.disabled = false;
}
}
</script>
</head>
<body>
<form name="frm">
<input type="text" name="t1" value="don't change me" onfocus="blurIt(this);">
<input type="checkbox" name="cb1" value="yes" onclick="processForm(this);">
</form>
</body>
</html>
said_fox
01-04-2003, 07:59 AM
To Mr Khaled
Your code is so good. i.e the blur is disabled, but, when I click on the text field to write inside it, the blur comes back again.
However, thank you very much for your help.:rolleyes:
khalidali63
01-04-2003, 08:04 AM
that is because I used onfocus event.just change it to onblur and u r good to go.
Khalid
said_fox
01-04-2003, 08:24 AM
Thank You Mr. Khalid for your help. Happy new year!