I must be being stupid. This should work right? I am trying to undisable the submit button of the form when the user types in the same as the ejs variable project.name
, but I get the error Cannot read property 'value' of null
Does this need to be ajax to be real-time or something? If so, I can do that instead
if(document.getElementById("monitorname").value == '<%=project.name%>'){
document.getElementById("deletesubmit").disabled = false;
}
I would be very grateful if someone could help me figure this out
Eddie
You could try something like this:
if (document.getElementById("monitorname").value.trim().toLowerCase() == '<%=project.name%>'.trim().toLowerCase()){
document.getElementById("deletesubmit").disabled = false;
}
EDIT: Where is the if satement placed exactly? Are you checking on user input?
Yes, I am checking user input, that’s why I thought I might need to use Ajax. I tried moving the script tags around to see if it was that. Is there a specific place I should put it? Your code didn’t fix the error
Thanks for trying to help!
Can I have an invite to the project?
Another good way to debug it is adding console.log(document.getElementById("monitorname").value.trim().toLowerCase(), '<%=project.name%>'.trim().toLowerCase())
and check the console on client-side.
Yay! Got it working with this code:
$('#monitorname').keyup(function(){
if ($("#monitorname").val() == '<%=project.name%>'){
$("#deletesubmit").prop('disabled', false);
}});
Thanks for the help!
It works so I ain’t complaining
1 Like