MyBB Community Forums

Full Version: More Site Questions.........
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Edit:

Ok. I have a contact form on my site, and have a JavaScript code to stop multiple submitting in one go. However, recently I have been getting lots and I think it may be because people have JavaScript turned off in their browser. I was talking to a friend this morning, and he said that the same effect could be done using php, and that it is more secure and reliable.

Thanks to Ddunk over at the MsgPlus! boards, I am now using this code:
<script type="text/javascript">
<!--
document.write('<input type="button" value="Submit" onclick="validateForm();">');
-->
</script>
<noscript><center>Sorry, you need javascript<br>turned on to use this form</noscript>
It works for accedental spam, but still, for spammers, all they have to do is load the page, then turn javascript off. Does anyone know of a code to make it check javascript is on after the user clicks submit, not when the page loads??

Thanks in advance.

k776

Well, according to the Support Tips posted by Ryan, im allowed to "Bump" the thread by double posting.

I have updated the info above so any help would be gladly appreciated.

k776
Those tips apply only to the Support Forum.

I said nothing about the General Chat forum. Wink

Besides... your thread was at top the whole time. Toungue
Well, the same principle (after all, this is a support question Smile )

And yeah, I know, I just can't wait to get my site released in a few weeks and these are the few last touches to the site.

k776

Edit: Ok, I talked to my friend again this morning. He said that session would be good and easy, but if I wanted an easier way, make a script that will prevent a user from clicking the button, as it would be greyed out with the words "Need Javascipt on to use form" if they didn't have javascript on.

Does anyone know any way of coding this type of thing??
Not a Support Question regarding MyBB. Wink

I highly suggest you look at www.w3schools.com. They've got great Coding References.

It's where I started out learning PHP.. Smile
Thank Ryan, but couldn't find anything useful. Have updated the first post. Please take a look.

k776
You could make the button a "button" button not a submit one, then in your validation code, add something like

document.[form name].submit();

Make sure your form tag has something like:

<form method="POST" action="blah.php" name="myform">

Which means you use..

document.myform.submit();

Oh, your input button would be type="button" not type="submit" too
Attached is the files. I dont understand so when you get a moment, can you edit them??

k776

[attachment=133]
[attachment=134]
[attachment=135]
<form method="post" action="<? echo $PHP_SELF; ?>" enctype="multipart/form-data" onsubmit='disableButton(this.mySubmit);return true;' name="contactform">


document.write('<input name="Submit" type="Button" value="Send Mail" onclick="disableButton(this); document.contactform.submit();">');
Thanks for that. Now user must have javascript on to make it work, if they load the page without javascript, it replaces the button with "You need javascirpt on.....", it stop them from submitting more than 1 in one go by turniung the button to processing. All is great. Althouh, one little picky thing:

A user load the page with javasciprt, the turns it off, the form no longer submits but doesn't alert them that they dont have javsciprt on.

My final question is this: Is there someway to add an alert saying "You have javascript turned off. Please turn it on then click submit again"

k776
Pages: 1 2