Saturday, January 10, 2009

Javascript: Function To Check Whether TextField is ReadOnly

The following Javascript function can be used to check whether the given control is read only or not?

Sample 1:

function isReadOnly()
{

var m = document.getElementById("TextBox1").getAttribute("Readonly");
if (m==true)
{
alert('Read Only!');
return true;
}

else

{

alert('Not Read Only');

return false;

}


}

Sample 2:


function isReadOnly(controlID)
{

var m = document.getElementById(
controlID).getAttribute("Readonly");

if (m==true)
{
alert('Read Only!');

return true;

}

else

{

alert('Not Read Only');

return false;

}


}

No comments: