Hi I am just curious why the onsubmit function won't respond if the validation function is enclosed inside: (function(){ })();
<form id="testform" name="entform" onsubmit="return promptChar()" method="post">
<input id="input-text" name="entchar" type="text" placeholder="Enter Text" />
<input type="submit" value="Send" />
</form>
<script>
(function(){
function promptChar(){
var field = document.getElementById('input-text').value;
if(field == "a"){
alert('hey');
return false
}
}
})();
</script>
https://jsfiddle.net/aqqn5u5v/
please also try to test it locally and copy the code