OK, so I have a button that needs to be disabled. I wrote a JavaScript function that is meant to detect if a field is blank/null, and if it is disable the save button next to a field. It would appear to be working as far as detecting the blank field, and throwing the alert, but no matter what I try as far as setting the button to disable. I cannot get it to do so.
Here is what I'm currently trying...
function validateBlank(){
var x = document.forms["FuForm"]["Field1"].value;
if (x=null || x == "") {
alert("Must Be Between 1 and 300 Characters");
document.getElementById("saveTest").setAttribute("disabled", "disabled");
return false;
}
}
I've also tried this variant...
document.getElementById("saveTest").disabled
and the button/link is setup like this.
<a href="#">
<img id="saveButton" src="${contextPath}/img/icon_sav.gif" name="saveTest" " alt="Disk icon. Save change" title="Save change"/>
</a>