I have this code:
<script language="javascript">
var noun=["cat","mat","rat"];
var verb=["like","is","see","sees"];
var object=["me","a+noun","the+noun"];
var subject=["I","a+noun","the+noun"];
var sentence=(subject+verb+object);
function checkCorrectness(){
var input=document.getElementbyId("userInput");
if(input==sentence)
{
alert("congratulations your sentence is correct");
}
else if(input=="null"||"")
{
alert("your entered a blank text, please enter sentence");
}
else{
alert("Sorry, Your sentence is incorrect, your sentence should be in the form of a subject, verb and object. please try again");
}
};
</script>
</head>
<body>
<h1><font size="3" color="black" face="comic sans ms">Welcome to Micro English</font></h1>
<h2><font size="2" color="blue" face="comic sans ms">Please Enter a sentence in micro English in the box below</font></h2>
<form onsubmit="checkCorrectness();">
<input type="text" name="input" id="userInput"/>
<input type="submit"value="go"/>
</form>
but when I click the "go" button nothing happens.what could be the problem? I have tried changing the type of input but it has never ran, I had a similar program that did run but I just cnt put my finger on the problem here. please help
var input=document.getElementbyId("userInput").value;enter code heresupposed to mean?valueenter code here`` ?else if(input=="null"||"")- you're checking for string comparison against the string"null", which I'm assuming is not what you want. Plus the||""won't work - the language doesn't work that way. You probably wantif (!input), which will look for any "falsy" value.