keyboard
05-19-2011, 04:57 AM
Hi every one.
I'm fairly new to javascript and I need some help with a script
This is what i've found be mashing together some scripts from a few different sites.
<HTML>
<HEAD>
<script type="text/javascript">
function notEmpty(){
var myTextField = document.getElementById('myText');
if(myTextField.value != "fred")
alert("You entered: " + myTextField.value);
else
var answer = alert("Correct")
if (answer){
}
else{
alert("Bye bye!")
window.location = "http://www.google.com/";
}
}
</script>
</HEAD>
<BODY>
<input type='text' id='myText' />
<input type='button' onclick='notEmpty()' value='Form Checker' />
</BODY>
</HTML>
I would like it if when you enter random text it comes up with an elert saying what you just entered. And when you enter the special word.... fred ...... it says correct and then redirects you to another page, in this case google.
It is nearly doing this however when you enter text that isn't fred it comes up with the alert like it's meant to, but then redirects you to google any way.
Any help on this would be appreciated
I'm fairly new to javascript and I need some help with a script
This is what i've found be mashing together some scripts from a few different sites.
<HTML>
<HEAD>
<script type="text/javascript">
function notEmpty(){
var myTextField = document.getElementById('myText');
if(myTextField.value != "fred")
alert("You entered: " + myTextField.value);
else
var answer = alert("Correct")
if (answer){
}
else{
alert("Bye bye!")
window.location = "http://www.google.com/";
}
}
</script>
</HEAD>
<BODY>
<input type='text' id='myText' />
<input type='button' onclick='notEmpty()' value='Form Checker' />
</BODY>
</HTML>
I would like it if when you enter random text it comes up with an elert saying what you just entered. And when you enter the special word.... fred ...... it says correct and then redirects you to another page, in this case google.
It is nearly doing this however when you enter text that isn't fred it comes up with the alert like it's meant to, but then redirects you to google any way.
Any help on this would be appreciated