miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

making Location field (or other simple text field) mandatory

 
Author Anonymous
Guest
#1 | Posted: 21 Jun 2007 23:48 
When registering how do you make it so they must enter a Location?

Author Paul
Lead Developer 
#2 | Posted: 22 Jun 2007 06:00 
I think the JavaScript solution would be the best and won't destroy the core files as well.

Apply the following changes modifying templates/user_dataform.html file:

1) at the very top, paste

<script type="text/javascript" src="https://www.minibb.com/forums/templates/form.js"></script>
2) In the section between JavaScript tags <script></script> paste new function:

function submitForm(){
var ind = document.forms['regform'];
if(trimTxt(ind.elements['login'].value)=='' || trimTxt(ind.elements['email'].value)=='' || (ind.elements['action'].value=='register' && (trimTxt(ind.elements['passwd'].value)=='' || trimTxt(ind.elements['passwd2'].value)=='') ) || trimTxt(ind.elements['from'].value)=='') { alert('Please, fill out all mandatory fields!'); return; }
else ind.submit();
}
3) Right after the variable {$warning} paste:

<noscript><br />JavaScript must be enabled to submit the profile!</noscript>

4) Replace the Submit button's code which says <input type="submit" value="{$userTitle}" class="inputButton" /> to:

<script type="text/javascript">
<!--
document.write('<input type="button" name="subbut" value="{$userTitle}" class="inputButton" onClick="submitForm();" />');
//-->
</script>

Now edit bb_plugins.php file and at the top of this file somewhere paste

/* Check location field */
if( ($action=='editprefs' OR $action=='register') and (!isset($_POST['from']) or trim($_POST['from'])=='') ) die('');
Any other mandatory text field may be implemented the same way...

Author Guest
~
#3 | Posted: 3 Apr 2012 05:18 
This only worked for me when I changed (input type="button") to (input type="submit")

Author Paul
Lead Developer 
#4 | Posted: 3 Apr 2012 11:42 
I'm not sure which way it worked for you... "Submit" type of input sends the form immediately; with the "button" type you have a chance to validate all fields and perform other JavaScript checks before the form is submitted. That's my code above is about.

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 making Location field (or other simple text field) mandatory
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the Private Messaging add-on: allow your miniBB-forums members to communicate with each other.


  ⇑