Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 9 Years, 7 Months, 2 Weeks ago How do I make a required field mybb 1.6.4
#1
Solved: 9 Years, 7 Months, 2 Weeks ago
I am having difficulty getting this to work when posting or making threads.

If a reply or thread is posted (submitted) without checking the box then the default mybb error page appears.

My version is 1.6.4

<input type="checkbox" name="checkbox" id="checkbox" value="{$requiredfields}">Please check</a>

I have a plan and will share it Smile I need to see if I can get it to work first.
#2
Solved: 9 Years, 7 Months, 2 Weeks ago
Couple of things;

1) Do you want to show error page when the user doesn't checked the check box ?
2) The code is wrong, the correct syntax may be;
<input type="checkbox" name="checkbox" id="checkbox" value="{$requiredfields}">Please check

Notice, I removed the ending </a> since its opening tag was not defined.
#3
Solved: 9 Years, 7 Months, 2 Weeks ago
(2012-06-13, 05:25 PM)Yaldaram Wrote: Couple of things;

1) Do you want to show error page when the user doesn't checked the check box ?
2) The code is wrong, the correct syntax may be;
<input type="checkbox" name="checkbox" id="checkbox" value="{$requiredfields}">Please check

Notice, I removed the ending </a> since its opening tag was not defined.

Yes I want the error page to show if the user does not check the box. I will test the code and get back to you.

Is {$requiredfields} the default for mybb? Or is this wrong?

Edit - No it still posted with the box unchecked.

This the whole code:

<tr>
<td class="trow1"><strong>Check The Box</strong></td>
<td class="trow1"><form action="transact.dll" method="POST" onSubmit="required" name="form">
<input type="checkbox" name="checkbox" id="checkbox" value="{$requiredfields}">check the box</a>
      </form>

<SCRIPT LANGUAGE="JavaScript">
<!--
function validate(frm) {
        if (frm.checkbox.checked==false)
    {
        alert("text will go here");
        return false;
    }
}
//-->
</SCRIPT></td>

</tr>

Just so you can see what I am doing - I probably have this completely wrong.

Full code so you can see what I am doing

<html>
<head>
<title>{$lang->post_reply_to}</title>
{$headerinclude}
<script type="text/javascript" src="jscripts/post.js?ver=1400"></script>
</head>
<body>
{$header}
{$preview}
{$maximageserror}
{$attacherror}
{$reply_errors}
<form action="newreply.php?tid={$tid}&amp;processed=1" method="post" enctype="multipart/form-data" name="input">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->post_new_reply}</strong></td>
</tr>
<tr>
<td class="tcat" colspan="2"><span class="smalltext"><strong>{$lang->reply_to}</strong></span></td>
</tr>
<tr>
<td class="trow2" width="20%"><strong>{$lang->post_subject}</strong></td>
<td class="trow2"><input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td>
</tr>
{$posticons}
<tr>
<td class="trow2" valign="top"><strong>{$lang->your_message}</strong><br />{$smilieinserter}</td>
<td class="trow2">
<textarea id="message" name="message" rows="20" cols="70" tabindex="2" >{$message}</textarea>
{$codebuttons}
{$multiquote_external}
</td>
</tr>
<tr>
<td class="trow1" valign="top"><strong>{$lang->post_options}</strong></td>
<td class="trow1"><span class="smalltext">
<label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="6"{$postoptionschecked['signature']} /> {$lang->options_sig}</label>
{$disablesmilies}
</span></td>
</tr>
{$modoptions}
{$subscriptionmethod}
{$captcha}
<tr>
<td class="trow1"><strong>Check The Box</strong></td>
<td class="trow1"><form action="transact.dll" method="POST" onSubmit="required" name="form">
<input type="checkbox" name="checkbox" id="checkbox" value="{$requiredfields}">check the box</a>
      </form>

<SCRIPT LANGUAGE="JavaScript">
<!--
function validate(frm) {
        if (frm.checkbox.checked==false)
    {
        alert("text will go here");
        return false;
    }
}
//-->
</SCRIPT></td>

</tr>

</table>

</form></td>
</tr>
</table>
{$attachbox}
<br />
<div align="center"><input type="submit" class="button" name="submit" value="{$lang->post_reply}" tabindex="3" accesskey="s" />  <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="4" />{$savedraftbutton}</div>
<input type="hidden" name="action" value="do_newreply" />
<input type="hidden" name="replyto" value="{$replyto}" />
<input type="hidden" name="posthash" value="{$posthash}" />
<input type="hidden" name="attachmentaid" value="" />
<input type="hidden" name="attachmentact" value="" />
<input type="hidden" name="quoted_ids" value="{$quoted_ids}" />
<input type="hidden" name="tid" value="{$tid}" />
{$editdraftpid}
</form>
{$forumrules}
{$threadreview}
{$footer}
</body>
</html>
#4
Solved: 9 Years, 7 Months, 2 Weeks ago
The file in action tag is "transact.dll" which I think is a computer/system file. You've to create a file like checking.php and then have to define its action tag.

Are you making something like this?
#5
Solved: 9 Years, 7 Months, 2 Weeks ago
If i just strip out that section of code to point to the relevant file in the mybb script maybe that will work.

I will try removing the whole line: form action="transact.dll"
#6
Solved: 9 Years, 7 Months, 2 Weeks ago
Actually, the way you're trying to do is not going to work. You've created HTML, that's good. But you also need to create a php file which do the rest of the job.

I think Aniruddh is doing that plugin so wait for his release. Smile
#7
Solved: 9 Years, 7 Months, 2 Weeks ago
Yes I think you are right, and my limited knowledge on the mybb script is making this fail miserably lol
#8
Solved: 9 Years, 7 Months, 2 Weeks ago
Having tried many methods I have to say this is more difficult than first thoughts. Grrrr.
#9
Solved: 9 Years, 7 Months, 2 Weeks ago
Sad I really want to make this work and it is just not happening.

It must be simple to point a checkbox for validation. I just cannot figure it out.

Every method I have tried will still post a thread or reply even with the checkbox unchecked.

It would be very much appreciated if someone can help me out a little. My MyBB coding is not the best so I need to so this with a step by step instruction please.
#10
Solved: 9 Years, 7 Months, 2 Weeks ago
Okay I am nearly there I think with this if I could get some help I think this will work.

Surely there is an easy way to get this to work on NEWREPLY and NEWTHREAD

<script type="text/javascript">
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
  {
  alert("Type a letter to say you are not a spammer!");
  return false;
  }
}
</script>
<form name="what_do_i_do_here" action="what_do_i_do_here" onsubmit="return validateForm()" method="post">
Type any letter here to state you are not a Spammer: <input type="text" name="fname">
<input type="submit" value="Submit">

That is the basics of a validation method, but i do not know where to point to in regards PHP validation and the like.

If anyone can help me with this I just know that you will ALL benefit from what I am trying to do.

See: http://articlechase.com/beyondnews/newre...p?tid=2110

You will see the part in the form at the bottom "Type any letter here to state you are not a Spammer:"

I cannot get the button to work, as replies can still be made even if no letter is typed.

Please anyone if you can help it would be very much appreciated, I have been trying for weeks and all I want to do is make it more difficult for the bots to get through for us all.
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)