miniBB ®
 
miniBB Community Forum
 | Forums | File Bank | Sign Up | Reply | Search | Statistics | Manual |
Galleries / Attachments Addon for miniBB Extend your miniBB-forums, attaching the images and files, get the File and Picture Attachments add-on!
Custom Tutorials and Modifications miniBB Community Forum / Custom Tutorials and Modifications /
Short link for this topic:

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
CEO
#2 | Posted: 22 Jun 2007 06:00 | Edited by: Paul
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="{$main_url}/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...
Custom Tutorials and Modifications miniBB Community Forum / Custom Tutorials and Modifications / making Location field (or other simple text field) mandatory Top
Your Reply Click this icon to move up to the quoted message

» Username  » Password 
You are welcome to post anonymously by entering a nickname with no password (if that nickname has not been taken by another member) or by leaving both fields empty. If you have a forums membership account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.

 
miniBB Community Forum Powered by Free Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts