I have tried coding some javascript for form that, when user typing certain word then the textfield below will automatically disable.The problem is, when i the tried the code in jsfiddle the code will run smoothly but when i use it in my project, it don't work. Can anybody explain what wrong with my code.
<script>
function matchWord(e){
if(document.getElementById('uname').value.trim === 'Unknown' || document.getElementById('uname').value.trim === 'unknown'){
document.getElementById('pword').disabled = true;
document.getElementById('response').disabled = true;
alert('you enter bannned name in the field');
}
else{
}
}
document.getElementById('uname').onkeyup = matchWord();
</script>
<html>
<body>
Name:<input type="text" name="uname" id="uname" placeholder="Username"><br>
password:<input type="password" name='pword' id='pword' placeholder="password"><br>
Responsibility:<select id = "response">
<option>---Responsibility---</option>
</select>
</body>
</html>