Here is a snippet of my code; it is from an HTML form page:
Phone Number:<input type="text" id="Phone" name="Phone" onkeyup="checkFirst();" /><br />
<p id="rabbit"></p> <!-- for testing -->
This is the input text field and I want to call upon my checkFirst function which is in the head section of the html, here is my checkFirst function
<script type="text/javasciprt">
document.getElementById("rabbit").innerHTML = "When";
function checkFirst(){
var numbers = 3; //document.getElementById("Phone").value.length;
document.getElementById("rabbit").innerHTML="Hello";
if (numbers <= 3) {
document.Phone.focus();
} else {
document.info_open.focus();
}
}
</script>
When I run this the, nothing happens to the element with the ip "rabbit". it does not change. I ran it with the Chrome debugger and it showed in the right hand panel that I have a reference error under which it says:
type: "not_defined"
The error is on the line of the element for phone input, why am I getting this error? I thought I defined type as ‘text’.
Change
to
Because the code runs perfectly in jsfiddle ( http://jsfiddle.net/yhFfc/ ).