Page 1 of 1

[RESOLVED] v2.3 Error checking on form Dropdown & Checkboxes

Posted: Mon Sep 19, 2011 5:35 am
by Raven
Hi, I've noticed that error checking is not being performed on form Options, Check boxes and Dropdown lists...

Submit a blank ticket to cause the errors to see what I mean: http://www.crikey-thatsmint.com/hesk23/index.php?a=add

Cheers

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Mon Sep 19, 2011 6:25 pm
by Klemen
They are checked, just not marked in red. Radio buttons and select boxes have a value selected that's why you don't get an error, but checkbox errors are reproted in your form ("Missing required field: Custom field 5").

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Mon Sep 19, 2011 10:40 pm
by Raven
Ahh makes sense... So, how can I have the drop down list show '--Please Select--' as a default value but it be a null value until someone selects something else?

I've tried to mirror the alterations made from 2.2 without success so far..

The check boxes highlight in red when I browse using my phone 'mobile safari' but don't get highlighted in firefox - not tested on any other browser.

Also, is there anyway to not have a default value for radio buttons (same as check boxes)?

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 9:23 am
by Klemen
I guess checkbox highlight depends on browser, some may not support that.

For select boxes you could add

Code: Select all

<option value="">-- Please select --</option>
just after

Code: Select all

<select name="'.$k.'" '.$cls.'>
in index.php (twice!).

Checkboxes are a bit more tricky because browsers select a default value if none is set. You would have to create an empty one in the same index.php before any other checkboxes, like

Code: Select all

<label><input type="checkbox" name="'.$k.'[]" value="" />Please select one of options below:</label><br />

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:08 pm
by Raven
Hi and thanks for the reply but that's exactly what I have for the drop-downs and although I've set three 'test options' (option 1, option 2 and option 3) it's initial state is 'option 1' as opposed to '--Please Select--'..?

I've also tried adding

Code: Select all

<select name="'.$k.'" '.$cls.' id="custom"><option SELECTED value="">- Please Select -</option>
and

Code: Select all

<select name="'.$k.'" '.$cls.' id="custom"><option SELECTED="SELECTED" value="">- Please Select -</option>
without success.

Any ideas?

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:15 pm
by Klemen
Like my previous post says, you need to edit that code in file index.php :wink:

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:17 pm
by Raven
I did/am... :?

**EDIT**
As you can see, the '- Please Select -' option is there and at the top of the list for both drop-downs but it's not initially selected: http://www.crikey-thatsmint.com/hesk23/index.php?a=add

Double checking the code for my version 2.2 installation of HESK it is ecactly the same except for the '.$cls.' part and works without any problems... Could this be the problem I wonder?

**EDIT 2**
Scrap that, just tried removing it and it still doesn't work... hmmm

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:28 pm
by Klemen
Hmm, try removing this as well (should be 4 times; I'm not testing tips I give here):

Code: Select all

strlen($k_value) == 0 || 
$cls is responsible for printing class="isError" (red borders) if a filed has been marked as required but missing.

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:33 pm
by Raven
Lol - I just removed

Code: Select all

if (strlen($k_value) == 0 || $k_value == $option)
and replaced it with

Code: Select all

if ($k_value == $option)
and it works fine now... Wonder why it is stripping out the initial '- Please Select -' option...?

Re: 2.3 - Error checking on form Options, Check boxes & Drop

Posted: Tue Sep 20, 2011 7:35 pm
by Raven
...and do I really need to remove

Code: Select all

strlen($k_value) == 0 ||
from the 'radio' buttons..?

PS
Added [RESOLVED] to the subject of this thread to help others as the initial question has been answered ;)