Disable Upload Until Field Filled

5 posts by 2 authors in: Forums > CMS Builder
Last Post: January 29, 2015   (RSS)

By Perchpole - January 28, 2015

Hello, All -

I've been working quite a lot with UploadForm3 and there's just one tiny bit of functionality I'm missing.

I want to force users to provide a file "title" before uploading a file. I've tried and failed using "$errorsAndAlerts" code - because none of this stops a user uploading a file.

What I think I need is a way of disabling the upload button until field "info1" has content.

I'm assuming this is a job for jQuery!

:0/

Perch

By claire - January 28, 2015

Hi Perch

Yes, it's a jQuery thing. You'll want to look at the .change handler, like so:

$('input[name=title]').change(function(){
  if(this.length < 1) {
    $('#uploadfile').hide();
  }
  else {
    $('#uploadfile').show();
  }
});

What this should do is show the upload field as long as the length of the string in the title field is greater than zero. You will also have to change 'uploadfile' to whatever ID you're using right now for the upload field.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By claire - January 29, 2015

Hey Perch

The point of checking for the length is that you can disable the button or hide the upload field if there's nothing in the box. The only real measure of checking if the user deletes their text is checking for a string length on the input with a length of zero!

If you can show me the page, I might be able to debug the JS there alone.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Perchpole - January 29, 2015

Thanks, Claire.

I know nothing. But for a moment I thought I did!

;o)

Perch