forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: yacenty on August 20, 2006, 01:36:44 pm

Title: How to force users to fill in all fields during uploading files?
Post by: yacenty on August 20, 2006, 01:36:44 pm
Hi, is there any method to force user to fill in all fields when he is uploading picture?
I would like to have anything in title, description and keywords,
Is it hard to modify uploading process to check if there is something in this field?

There is one rule in my gallery that picture has to have all this filed filled in, now I have a lot of work to check if picture has this field when I'm accepting pictures.

I hope sb can help me :)

Kind regards,
YacentY
Title: Re: How to force users to fill in all fields during uploading files?
Post by: Sami on August 20, 2006, 03:44:07 pm
You need to put custom javascript:
Disable upload button and check the value of those fields with javascript and enable button when all fields have a value
Title: Re: How to force users to fill in all fields during uploading files?
Post by: yacenty on August 20, 2006, 03:55:23 pm
I have no experince in JS, could You give some exapmle how to do it?
Kind regards,
YacentY
Title: Re: How to force users to fill in all fields during uploading files?
Post by: Sami on August 20, 2006, 07:59:05 pm
okey you need to change upload.php

- first of all you need to change this (under text_box_input function around line 112)
Code: [Select]
<input type="text" style="width: 100%" name="$name" maxlength="$max_length" value="$default" class="textinput" />
with this
Code: [Select]
<input type="text" style="width: 100%" name="$name" maxlength="$max_length" value="$default" class="textinput" onKeyUP="formcheck();" onfocus="formcheck();"/>

- Then you should change this (under text_area_input function around line 159 )
Code: [Select]
<textarea name="$name" rows="5" cols="40" class="textinput" style="width: 100%;" onKeyDown="textCounter(this, $max_length);" onKeyUp="textCounter(this, $max_length);">$default</textarea>
with this
Code: [Select]
<textarea name="$name" rows="5" cols="40" class="textinput" style="width: 100%;" onKeyDown="textCounter(this, $max_length);" onKeyUp="textCounter(this, $max_length);formcheck();" onfocus="formcheck();">$default</textarea>

- Then you should change this (under form_alb_list_box function around line 185)
Code: [Select]
<select name="$name" class="listbox">
with this
Code: [Select]
<select name="$name" class="listbox" onchange="formcheck();">

- and You need to replace the  open_form function with this new function
Code: [Select]
function open_form($path) {

    echo <<<EOT
    <script language="javascript" type="text/javascript">
    function textCounter(field, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
    }
function formcheck(){ // added for fill all fields mod by b.mossavari
for(i=0;i<3;i++){
d=document.forms[i];
if(x=d.caption){
if(d.title.value!='' && d.caption.value!='' && d.keywords.value!=''){
d.sub_button.disabled=false;
}else{
d.sub_button.disabled=true;
}
}
}
}

    </script>
    <form method="post" action="$path" enctype="multipart/form-data" onmouseover="formcheck();">
EOT;
}
and then replace (under close_form function around line 354 )
Code: [Select]
<input type="submit" value="{$button_value}" class="button" />
with this
Code: [Select]
<input type="submit" value="{$button_value}" class="button" id="sub_button" name="sub_button"/>

This will disable continue button on http upload form with default setting ;)
Title: Re: How to force users to fill in all fields during uploading files?
Post by: yacenty on August 20, 2006, 09:49:49 pm
I did it but unfortunately wrong button is disabled :(
Continue button on page where only files are selected is blocked. even if i put all ten files button is blocked :(

I would like to block button on the page where picture and title, description and keywords are shown :)
is it possible to do it?

Kind regards
YacentY
Title: Re: How to force users to fill in all fields during uploading files?
Post by: Sami on August 20, 2006, 11:11:51 pm
Sorry I didn't check that with my test bed ::)
I update my last post and if you follow the steps you'll be fine ;)
Title: Re: How to force users to fill in all fields during uploading files?
Post by: yacenty on August 21, 2006, 06:40:07 pm
now it works perfect:)
thank you very much :)