Revision: 1800
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1800&view=rev
Author:   cimorrison
Date:     2011-03-03 10:29:59 +0000 (Thu, 03 Mar 2011)

Log Message:
-----------
Fixed client side validation to check for mandatory custom checkbox inputs.

Modified Paths:
--------------
    mrbs/trunk/INSTALL
    mrbs/trunk/web/edit_entry.php
    mrbs/trunk/web/systemdefaults.inc.php

Modified: mrbs/trunk/INSTALL
===================================================================
--- mrbs/trunk/INSTALL  2011-03-01 09:53:06 UTC (rev 1799)
+++ mrbs/trunk/INSTALL  2011-03-03 10:29:59 UTC (rev 1800)
@@ -233,6 +233,11 @@
 In the case of a select field, this adds an empty value to the dropdown
 list.
 
+Making a checkbox field mandatory is possible and requires the
+checkbox to be ticked before the form can be submitted.   This can be
+useful for example for requiring users to accept terms of service or
+terms and conditions.
+
 3)
 
 You can also specify that a field is private, ensuring that the contents

Modified: mrbs/trunk/web/edit_entry.php
===================================================================
--- mrbs/trunk/web/edit_entry.php       2011-03-01 09:53:06 UTC (rev 1799)
+++ mrbs/trunk/web/edit_entry.php       2011-03-03 10:29:59 UTC (rev 1800)
@@ -588,7 +588,13 @@
     $.each(mandatory_fields,
            function(index, value)
            {
-             if ($("#"+value).val() == '')
+             var field = $("#"+value);
+             <?php
+             // If it's a checkbox then it needs to be checked.    If it's
+             // an ordinary field then it must have some content.
+             ?>
+             if ( ((field.attr('type').toLowerCase() == 'checkbox') && 
!field.attr('checked')) ||
+                  (field.val() == '') )
              {
                label = $("label[for="+value+"]").html();
                label = label.replace(/:$/, '');

Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php       2011-03-01 09:53:06 UTC (rev 
1799)
+++ mrbs/trunk/web/systemdefaults.inc.php       2011-03-03 10:29:59 UTC (rev 
1800)
@@ -527,9 +527,10 @@
 
 $is_mandatory_field = array();
 // You can define custom entry fields to be mandatory by setting
-// items in the array $is_mandatory_field. For example:
+// items in the array $is_mandatory_field.   (Note that making a checkbox
+// field mandatory means that the box must be checked.)   For example:
 
-// $is_mandatory_field['entry.coffee_required'] = true;
+// $is_mandatory_field['entry.terms_and_conditions'] = true;
 
  
 /***********************************************


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to