Click to See Complete Forum and Search --> : Textbox & Buttons Things


lmccord2
01-25-2003, 06:39 PM
Can anyone help me with this - first, I need a script where if someone clicks a button twice in a row, an alert box comes up and tells them that they clicked it twice, then it refreshes the page. The other script I need, is for a textbox. If someone writes some particular word, like EzBoard, then clicks the Submit button, it says they can't write that word, then it refreshes the page. Will any one help?

Jona
01-25-2003, 09:26 PM
Yea, first script...

<input type="button" onDblClick="alert('Only click once, please!'); window.location.reload()">

Second...
<SCRIPT>
if(document.frm.textarea1.indexOf("EzBoard") {
alert("You cannot use that word");
window.location.reload()
}
</SCRIPT>
<FORM name="frm">
<TEXTAREA name="textarea1">
</TEXTAREA>

lmccord2
01-26-2003, 09:08 AM
Thanks, but I can't get my second one to work, you know the textbox one?

Jona
01-26-2003, 04:17 PM
OK, let's try a function...

<SCRIPT>
function test() {
if(document.myForm.textarea1.indexOf("EzBoard") {
alert("You cannot post that word");
window.location.reload()
} }
</SCRIPT>
</HEAD>
<BODY>
<Form name="myForm">
<textarea name="textarea1">
</textarea><br>
<input type=button onClick="test()" value="TEST!">
</form>

lmccord2
01-26-2003, 06:10 PM
hmm... I used to know JavaScript by reading millions of tutorials lol but havn't done it for ages and forgot how to work with it lol... I can't get that script to work either. Heres my page...

<html>
<head>
<title>tests</title>

<SCRIPT>
function test() {
if(document.myForm.textarea1.indexOf("EzBoard") {
alert("You cannot post that word");
window.location.reload()
} }
</SCRIPT>

</head>
<body>

<Form name="myForm">
<textarea name="textarea1"> </textarea><br>
<input type=button onClick="test()" value="TEST!">
</form>

</body>
</html>

I can't find the problem?

Jona
01-26-2003, 06:21 PM
Heh, I can't find it either... :confused:

First of all, notice we are missing a )

if(document.myForm.textarea1.indexOf("EzBoard") {

Should be:

if(document.myForm.textarea1.indexOf("EzBoard")) {

But I tried that, and it has a problem too!
Hmmmmmmmm..............

Jona
01-26-2003, 06:32 PM
THE IDIOT THAT I AM!!!!!!!!!!

I forgot....

<html>
<head>
<title>tests</title>

<SCRIPT>
function test() {
if(document.myForm.textarea1.value.indexOf("EzBoard")) {
alert("You cannot post that word");
window.location.reload()
} }
</SCRIPT>

</head>
<body>

<Form name="myForm">
<textarea name="textarea1"> </textarea><br>
<input type=button onClick="test()" value="TEST!">
</form>

</body>
</html>


value.indexOf("")) with the last parenthesis and value!

*Hits himself in face*

lmccord2
01-27-2003, 04:18 PM
That works - but - your still the idiot that you are :p. lol j/k but any word I enter brings up the pop-up window. You forgot the { else } things lol. I'll fix that. Thanks.

lmccord2
01-27-2003, 04:21 PM
Hmm that didn't work either, when I added else...

<html>
<head>
<title>tests</title>

<SCRIPT>
function test() {
if(document.myForm.textarea1.value.indexOf("EzBoard")) {
alert("You cannot post that word");
window.location.reload()

}
{
else
}
}
</SCRIPT>

</head>
<body>

<Form name="myForm">
<textarea name="textarea1"> </textarea><br>
<input type=button onClick="test()" value="TEST!">
</form>

</body>
</html>

Jona
01-27-2003, 04:50 PM
I didn't test it completely :)

Yea, the else worked for me. Without the else I see where you're coming from. Are you using Netscape? It works perfectly in IE6. You may try, "else { return false }" or something like that.

lmccord2
01-27-2003, 04:52 PM
I use IE6. Okies I'll try the false thingy

Webskater
01-27-2003, 04:55 PM
function test()
{
if(document.myForm.textarea1.value.indexOf("EzBoard"))
{
alert("You cannot post that word");
window.location.reload()
}
else
{
}
}


The braces after else were wrong.

lmccord2
01-27-2003, 05:00 PM
Thanks for all your help. But Webskater, that don't work either =/ - lol

Jona
01-27-2003, 05:26 PM
Are you on a Mac?

That works fine for me. Let me put it here again:
<SCRIPT>
function test() {
if(document.myForm.textarea1.value.indexOf("EzBoard")) {
alert("You cannot post that word");
window.location.reload()
} else {
} }
</SCRIPT>

If that doesn't work, you must have JavaScript disabled or something!

lmccord2
01-27-2003, 06:11 PM
I'm on a Windows 98, IE v6

I'll try it one more time.

lmccord2
01-27-2003, 06:15 PM
Sorry, it don't work :(.

Jona
01-27-2003, 06:47 PM
That's weird: it works perfectly for me...

if(document.formName.textarea.value=="EzBoard") {
alert("but this only works if they ONLY typed EzBoard!")
}

......