1) I am using the well known PHP code (below) to display the categories. However I would like make this drop down required. If I am correct there is no markup for me to use 'required'. How can I make my categories required?
2) If the user fails image verification the file upload element gets cleared. I have 'try to republish' selected and it works for the input box, drop down and text area. Just not for the file upload element.
3) Also, when the image verification fails the page refreshes. In my case the form is not at the top of the page so the user does not immediately see the image verification failure notice. Any ideas on how to deal with this?
echo JHTML::_('list.category', 'catid', '21');
2) If the user fails image verification the file upload element gets cleared. I have 'try to republish' selected and it works for the input box, drop down and text area. Just not for the file upload element.
3) Also, when the image verification fails the page refreshes. In my case the form is not at the top of the page so the user does not immediately see the image verification failure notice. Any ideas on how to deal with this?
Hi Larry,
#1- in the JS code box:
#2- I don't think this is possible anyway!
#3- maybe you add some JS code to your form to focus on some element if the post array is not empty like:
in the JS code box too!
Cheers
Max
#1- in the JS code box:
window.addEvent('domready', function() {
$('catid').addClass('required');
});
#2- I don't think this is possible anyway!
#3- maybe you add some JS code to your form to focus on some element if the post array is not empty like:
<?php
if($_POST){
?>
window.addEvent('domready', function() {
$('elementid').focus();
});
<?php
}
?>
in the JS code box too!
Cheers
Max
Wow. Just goes to show what I know. I was expecting 1 and 3 to be hard.
1) I think we're on the right track. Add 'required' didn't quite do it. I tried this:
That almost works. Unfortunately there is a value (of 0) for "select a category". That passes validation. If I remove that (via firebug) it works! Any idea how to get JS to remove that value? Also, is there a way to add the 'title' for the validation message?
3) Worked great. Great idea. Thanks!
1) I think we're on the right track. Add 'required' didn't quite do it. I tried this:
window.addEvent('domready', function() {
$('catid').addClass('cf_inputbox validate-selection');
$('catid').removeClass('inputbox');
});
That almost works. Unfortunately there is a value (of 0) for "select a category". That passes validation. If I remove that (via firebug) it works! Any idea how to get JS to remove that value? Also, is there a way to add the 'title' for the validation message?
3) Worked great. Great idea. Thanks!
Hi LarryD,
Set the value of the 'dummy' option to value='' (instead of value='0') then it won't have a value and will be ignored by the validation check.
Bob
Set the value of the 'dummy' option to value='' (instead of value='0') then it won't have a value and will be ignored by the validation check.
Bob
But how can I do that? The values are generated with the code:
Any idea how to do that in JS?
If this isn't possible I guess I can simply hard code the categories instead of automatically generating. That should work but suffer from the obvious maintenance problems.
echo JHTML::_('list.category', 'catid', '21');
Any idea how to do that in JS?
If this isn't possible I guess I can simply hard code the categories instead of automatically generating. That should work but suffer from the obvious maintenance problems.
Hi LarryD,
I think that you can do it in that command, the full paramtere list is
Bob
I think that you can do it in that command, the full paramtere list is
$name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1
and tha tlast one should turn off the 'select category' option. So tryecho JHTML::_('list.category', 'catid', '21', '', '', 'ordering', 1, 0);
Bob
I didn't realize that was the full signature. I tried it but no luck.
Since it removes the 'Select a category' value the box defaults to the first category and also passes through validation.
No biggie. I'll either live with the inability to validate the category or hard code the categories. The 'select a category' is staring them in the face anyway. 😉
For the sake of learning something I am willing to try anything if you get any more ideas. But I am OK with moving on at this point. Thanks for all your help on this.
Since it removes the 'Select a category' value the box defaults to the first category and also passes through validation.
No biggie. I'll either live with the inability to validate the category or hard code the categories. The 'select a category' is staring them in the face anyway. 😉
For the sake of learning something I am willing to try anything if you get any more ideas. But I am OK with moving on at this point. Thanks for all your help on this.
Hi LarryD,
I think "required" should do it! 🙄
try this code to fix the 0 issue :
Cheers
Max
I think "required" should do it! 🙄
try this code to fix the 0 issue :
window.addEvent('domready', function() {
$('catid').options[0].setProperty('value', '');
$('catid').addClass('required');
});
Cheers
Max
This topic is locked and no more replies can be posted.