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

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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
Last edited by Raven on Tue Sep 20, 2011 7:37 pm, edited 1 time in total.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

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

Post 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").
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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)?
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

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

Post 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 />
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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?
Last edited by Raven on Tue Sep 20, 2011 7:15 pm, edited 1 time in total.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

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

Post by Klemen »

Like my previous post says, you need to edit that code in file index.php :wink:
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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
Last edited by Raven on Tue Sep 20, 2011 7:30 pm, edited 1 time in total.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

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

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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...?
Raven
Posts: 172
Joined: Sat Jun 20, 2009 12:39 am

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

Post 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 ;)
Post Reply