[jQuery] Re: Disable Submit

2010-01-17 Thread ryan.j
or you can bind to $(#your-form).submit(function({ ... }); if you're
making your JS unobtrusive


On Jan 16, 6:41 pm, Viz skillipedia skillipe...@googlemail.com
wrote:
 You will need just this tiny js script:

 function  disableOnSubmit(form ){

 for (var i = 0; i  form.length; i++){
                 var e = form.elements[i];

                 if (e.type.toLowerCase() == button || e.type.toLowerCase()
 == reset || e.type.toLowerCase() == submit) {

                     e.disabled=true;

                 }
               }

 }

  and  then add :

 form method=POST action=/account name=fm   onsubmit=disableOnSubmit(
 document.fm) 

 That's all what you need - i think


Re: [jQuery] Re: Disable Submit

2010-01-16 Thread Viz skillipedia
You will need just this tiny js script:


function  disableOnSubmit(form ){

for (var i = 0; i  form.length; i++){
var e = form.elements[i];

if (e.type.toLowerCase() == button || e.type.toLowerCase()
== reset || e.type.toLowerCase() == submit) {

e.disabled=true;

}
  }
}

 and  then add :

form method=POST action=/account name=fm   onsubmit=disableOnSubmit(
document.fm) 

That's all what you need - i think


[jQuery] Re: Disable Submit

2010-01-12 Thread MorningZ
Personally i suggest using BlockUI to overlay the whole form... that
way
1) not possible for your user to resubmit
2) gives dead obvious indication something is going on
3) simple as can be to use

On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I have a form i am submitting via Ajax. So after submit while its waiting
 for response i have my little spinner so user knows something is happening.
 But how can i disable the submit while its thinking waiting for a response
 so the user is not sitting there clicking submit over and over.

 Using this for my js as of now;

 $('#new_set').live('click', addRecord);

  function addRecord() {

  var data = $('#add').serialize();

  $(#add).slideToggle('fast');
  $('.flash').prepend('div class=saving/div');
  //$('#new_set').die('click');
  $.ajax({
   type: post,
          url: /manage/awards/add,
          data: data,
          dataType: 'json',
          success: function(response){
    if (response.status === true) {
     alert(response.status);

      $('.saving').remove();

    } else {
                 //$('#new_set').live('click');
     alert(response.status);
     $('.saving').remove();

    }
   }
  });
     }

 I tried adding $('#new_set').die('click'); but then it never submitted.

 Thanks

 Dave


RE: [jQuery] Re: Disable Submit

2010-01-12 Thread Dave Maharaj :: WidePixels.com
Ok thanks.sounds good to me.

Will check it out.

Dave 

-Original Message-
From: MorningZ [mailto:morni...@gmail.com] 
Sent: January-12-10 4:42 PM
To: jQuery (English)
Subject: [jQuery] Re: Disable Submit

Personally i suggest using BlockUI to overlay the whole form... that way
1) not possible for your user to resubmit
2) gives dead obvious indication something is going on
3) simple as can be to use

On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I have a form i am submitting via Ajax. So after submit while its 
 waiting for response i have my little spinner so user knows something is
happening.
 But how can i disable the submit while its thinking waiting for a 
 response so the user is not sitting there clicking submit over and over.

 Using this for my js as of now;

 $('#new_set').live('click', addRecord);

  function addRecord() {

  var data = $('#add').serialize();

  $(#add).slideToggle('fast');
  $('.flash').prepend('div class=saving/div');
  //$('#new_set').die('click');
  $.ajax({
   type: post,
          url: /manage/awards/add,
          data: data,
          dataType: 'json',
          success: function(response){
    if (response.status === true) {
     alert(response.status);

      $('.saving').remove();

    } else {
                 //$('#new_set').live('click');
     alert(response.status);
     $('.saving').remove();

    }
   }
  });
     }

 I tried adding $('#new_set').die('click'); but then it never submitted.

 Thanks

 Dave
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10
04:05:00



[jQuery] Re: Disable Submit

2010-01-12 Thread MorningZ
Dave

here's a quick 2 minute example of this topic and the other topic

http://jsbin.com/efona/edit (code)
http://jsbin.com/efona (run)

very little jQuery to wire that up :-)


[jQuery] Re: Disable Submit

2010-01-12 Thread MorningZ
btw, i forgot to add return false; to the end of both button
events there, that would be needed


[jQuery] Re: Disable Submit

2010-01-12 Thread Scott Sauyet
On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I have a form i am submitting via Ajax. So after submit while its waiting
 for response i have my little spinner so user knows something is happening.
 But how can i disable the submit while its thinking waiting for a response
 so the user is not sitting there clicking submit over and over.

MorningZ's suggestion is good, but there is another approach that is
always worth considering for any long-running function that you don't
want started while it's already running.

function myLongRunningFunc() {
if (arguments.callee.running) return;
arguments.callee.running = true;

// your processing here

arguments.callee.running = false;
}

This is simpler than you need, if you have multiple forms to submit,
so you'd have to store the running flag in the form, not the function,
but it's not too hard to modify.

Here's a modification of MorningZ's page:

http://jsbin.com/upilo (code http://jsbin.com/upilo/edit)

I think this is incomplete, because a form can be submitted in other
ways than by the click of a particular button, but some variation of
this might do.

It's not that I think this is a better solution than blockUI, but it's
a useful technique in its own right.

Cheers,

  -- Scott


RE: [jQuery] Re: Disable Submit

2010-01-12 Thread Dave Maharaj :: WidePixels.com
Looks good .

Thanks will try to add that to my site and see how it goes.

Dave 

-Original Message-
From: Scott Sauyet [mailto:scott.sau...@gmail.com] 
Sent: January-12-10 6:06 PM
To: jQuery (English)
Subject: [jQuery] Re: Disable Submit

On Jan 12, 2:49 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 I have a form i am submitting via Ajax. So after submit while its 
 waiting for response i have my little spinner so user knows something is
happening.
 But how can i disable the submit while its thinking waiting for a 
 response so the user is not sitting there clicking submit over and over.

MorningZ's suggestion is good, but there is another approach that is always
worth considering for any long-running function that you don't want started
while it's already running.

function myLongRunningFunc() {
if (arguments.callee.running) return;
arguments.callee.running = true;

// your processing here

arguments.callee.running = false;
}

This is simpler than you need, if you have multiple forms to submit, so
you'd have to store the running flag in the form, not the function, but it's
not too hard to modify.

Here's a modification of MorningZ's page:

http://jsbin.com/upilo (code http://jsbin.com/upilo/edit)

I think this is incomplete, because a form can be submitted in other ways
than by the click of a particular button, but some variation of this might
do.

It's not that I think this is a better solution than blockUI, but it's a
useful technique in its own right.

Cheers,

  -- Scott
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.725 / Virus Database: 270.14.130/2607 - Release Date: 01/12/10
04:05:00



[jQuery] Re: Disable submit button with Validation plugin

2009-08-19 Thread fieory

Problem solved..

$().ready(function() {
var container = $(div.container);

var validator = $(#form_request_item).validate({
  errorContainer: container,
  errorLabelContainer: $(ul, container),
  wrapper: li,
  meta: validate,
  submitHandler: function(form) {
  $(button).attr('disabled', 'disabled');
  form.submit();
  }
});
  });

On Aug 18, 1:37 pm, fieory fie...@gmail.com wrote:
 Hi Jörn,

 I'm totally newbie toJqueryand i'm usingjQueryvalidationplug-in
 1.5.5 written by you to validate form. I've tried todisablesubmitbuttonbased 
 on example given but it didn't work(refer to code below).
 Then have tried to change form to #form_request_item but it still
 same. I have also tried to place it injQueryfile but didn't work
 either. May be because I'm not so familiar and wrongly placed it.
 Would really appreciate if you could help. Thank you so much.

 $().ready(function() {
     var container = $(div.container);

     var validator = $(#form_request_item).validate({
       errorContainer: container,
       errorLabelContainer: $(ul, container),
       wrapper: li,
       meta: validate,
       submitHandler: function(form) {
       $(form).find(:submit).attr(disabled, disabled).attr
 (value,Submitting...);
       form.submit();
       }
     });
   });

 - Fieory -

 On Aug 10, 9:01 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com
 wrote:

  Try this:

  $(document).ready(function() {
     $(#myForm).validate({
       submitHandler: function(form) {
         $(form).find(:submit).attr(disabled, true).attr(value,
  Submitting...);
         form.submit();
      }
    })

  });

  Jörn

  On Mon, Aug 10, 2009 at 9:40 AM, Rich Sturimcosmos99...@gmail.com wrote:
   $(document).ready(function() {
      $(#myForm).validate()
   });


[jQuery] Re: Disable submit button with Validation plugin

2009-08-18 Thread fieory

Hi Jörn,

I'm totally newbie to Jquery and i'm using jQuery validation plug-in
1.5.5 written by you to validate form. I've tried to disable submit
button based on example given but it didn't work(refer to code below).
Then have tried to change form to #form_request_item but it still
same. I have also tried to place it in jQuery file but didn't work
either. May be because I'm not so familiar and wrongly placed it.
Would really appreciate if you could help. Thank you so much.

$().ready(function() {
var container = $(div.container);

var validator = $(#form_request_item).validate({
  errorContainer: container,
  errorLabelContainer: $(ul, container),
  wrapper: li,
  meta: validate,
  submitHandler: function(form) {
  $(form).find(:submit).attr(disabled, disabled).attr
(value,Submitting...);
  form.submit();
  }
});
  });

- Fieory -

On Aug 10, 9:01 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com
wrote:
 Try this:

 $(document).ready(function() {
    $(#myForm).validate({
      submitHandler: function(form) {
        $(form).find(:submit).attr(disabled, true).attr(value,
 Submitting...);
        form.submit();
     }
   })

 });

 Jörn

 On Mon, Aug 10, 2009 at 9:40 AM, Rich Sturimcosmos99...@gmail.com wrote:
  $(document).ready(function() {
     $(#myForm).validate()
  });




[jQuery] Re: Disable submit button with Validation plugin

2009-08-11 Thread Rich Sturim

thank you Jörn -- that works

On Aug 10, 9:01 am, Jörn Zaefferer joern.zaeffe...@googlemail.com
wrote:
 Try this:

 $(document).ready(function() {
    $(#myForm).validate({
      submitHandler: function(form) {
        $(form).find(:submit).attr(disabled, true).attr(value,
 Submitting...);
        form.submit();
     }
   })

 });

 Jörn

 On Mon, Aug 10, 2009 at 9:40 AM, Rich Sturimcosmos99...@gmail.com wrote:
  $(document).ready(function() {
     $(#myForm).validate()
  });




[jQuery] Re: Disable submit button with Validation plugin

2009-08-10 Thread Jörn Zaefferer

Try this:

$(document).ready(function() {
   $(#myForm).validate({
 submitHandler: function(form) {
   $(form).find(:submit).attr(disabled, true).attr(value,
Submitting...);
   form.submit();
}
  })
});

Jörn

On Mon, Aug 10, 2009 at 9:40 AM, Rich Sturimcosmos99...@gmail.com wrote:
 $(document).ready(function() {
    $(#myForm).validate()
 });


[jQuery] Re: disable submit not working in IE7

2009-01-27 Thread GBartels

Thanks Mike!

Your script mostly works in IE once appended with });

The message displays and the form submits which is what it needs to
do. IE still has a little weird behavior in that it takes two clicks
to submit the form. On the first click, the form jumps a bit. It's
then necessary to reposition the cursor and on the second click the
message displays and submits. Firefox still working as expected.



On Jan 26, 5:41 pm, Mike Alsup mal...@gmail.com wrote:
  The button is indeed of type=submit and the form was working in IE
  prior to adding the above script.

  I also changed the attribute value to true (removing the quotes).

  Sadly, I'm still getting the same results in IE.

  On Jan 26, 4:10 pm, Karl Swedberg k...@englishrules.com wrote:

   A couple things you might want to look at:

   1. Does your button have type=submit ? It will need to if you want  
   to submit with it in IE.

   2. The disabled attribute value should be true, not true.

   --Karl

   
   Karl Swedbergwww.englishrules.comwww.learningjquery.com

   On Jan 26, 2009, at 4:55 PM, GBartels wrote:

I'm using JQuery 1.2.6 with the following script:

script type=text/javascript!--
$(document).ready(function(){ $(button.submitButton).click(function
() {
$(this).attr(disabled,true).html(Processing, please wait...);
$(button).attr(disabled,true); }) });
// --/script

It works as expected in FF3 but is is slightly broken in
IE7. On initial click, the submit button appears to take focus, on
second
click, the Processing... message appears and the button is disabled.
The
problem is that it the form is then never submitted. Any ideas on how
I might fix this to work in IE7 as well?

 Untested:

 $('button.submitButton').click(function() {
     $(this).blur().html('Processing, please wait...');
     this.disabled = true;
     this.form.submit();
     return false;

 });


[jQuery] Re: disable submit not working in IE7

2009-01-26 Thread Karl Swedberg

A couple things you might want to look at:

1. Does your button have type=submit ? It will need to if you want  
to submit with it in IE.


2. The disabled attribute value should be true, not true.

--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jan 26, 2009, at 4:55 PM, GBartels wrote:



I'm using JQuery 1.2.6 with the following script:

script type=text/javascript!--
$(document).ready(function(){ $(button.submitButton).click(function
() {
$(this).attr(disabled,true).html(Processing, please wait...);
$(button).attr(disabled,true); }) });
// --/script

It works as expected in FF3 but is is slightly broken in
IE7. On initial click, the submit button appears to take focus, on
second
click, the Processing... message appears and the button is disabled.
The
problem is that it the form is then never submitted. Any ideas on how
I might fix this to work in IE7 as well?

Thanks!




[jQuery] Re: disable submit not working in IE7

2009-01-26 Thread GBartels

Thank you Karl for the reply.

The button is indeed of type=submit and the form was working in IE
prior to adding the above script.

I also changed the attribute value to true (removing the quotes).

Sadly, I'm still getting the same results in IE.




On Jan 26, 4:10 pm, Karl Swedberg k...@englishrules.com wrote:
 A couple things you might want to look at:

 1. Does your button have type=submit ? It will need to if you want  
 to submit with it in IE.

 2. The disabled attribute value should be true, not true.

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On Jan 26, 2009, at 4:55 PM, GBartels wrote:



  I'm using JQuery 1.2.6 with the following script:

  script type=text/javascript!--
  $(document).ready(function(){ $(button.submitButton).click(function
  () {
  $(this).attr(disabled,true).html(Processing, please wait...);
  $(button).attr(disabled,true); }) });
  // --/script

  It works as expected in FF3 but is is slightly broken in
  IE7. On initial click, the submit button appears to take focus, on
  second
  click, the Processing... message appears and the button is disabled.
  The
  problem is that it the form is then never submitted. Any ideas on how
  I might fix this to work in IE7 as well?

  Thanks!


[jQuery] Re: disable submit not working in IE7

2009-01-26 Thread Mike Alsup

 The button is indeed of type=submit and the form was working in IE
 prior to adding the above script.

 I also changed the attribute value to true (removing the quotes).

 Sadly, I'm still getting the same results in IE.

 On Jan 26, 4:10 pm, Karl Swedberg k...@englishrules.com wrote:

  A couple things you might want to look at:

  1. Does your button have type=submit ? It will need to if you want  
  to submit with it in IE.

  2. The disabled attribute value should be true, not true.

  --Karl

  
  Karl Swedbergwww.englishrules.comwww.learningjquery.com

  On Jan 26, 2009, at 4:55 PM, GBartels wrote:

   I'm using JQuery 1.2.6 with the following script:

   script type=text/javascript!--
   $(document).ready(function(){ $(button.submitButton).click(function
   () {
   $(this).attr(disabled,true).html(Processing, please wait...);
   $(button).attr(disabled,true); }) });
   // --/script

   It works as expected in FF3 but is is slightly broken in
   IE7. On initial click, the submit button appears to take focus, on
   second
   click, the Processing... message appears and the button is disabled.
   The
   problem is that it the form is then never submitted. Any ideas on how
   I might fix this to work in IE7 as well?


Untested:

$('button.submitButton').click(function() {
$(this).blur().html('Processing, please wait...');
this.disabled = true;
this.form.submit();
return false;
});


[jQuery] Re: Disable Submit Button

2008-10-14 Thread Abel Mohler

The easiest way would be to have an id on the button like:
input type=submit id=submit /

and then the jQuery would be:
$(document).ready(function() {
$(#submit).attr(disabled, disabled);
});

On Oct 14, 2:12 am, Rahul Sinha [EMAIL PROTECTED] wrote:
 Hello,

 Please go through the below given requirement and provide me help
 asap.

 disable the submit button until the user has scrolled all the way
 through the agreement
 How can this be done using jquery if not then using pure js.

 Thanks
 Rahul


[jQuery] Re: Disable Submit button if no text entered

2008-05-16 Thread sashabe


Yes, but it seems that the script checks the input length only one time at
page load, and then button's state doesn't change if you continue to type or
delete input's content. 

Michael E. Carluen-2 wrote:
 
 
 Another suggestion will be to get the length of the field:
 
 var t = ($('#post_name').val()).length;
   if (t  0) {
   $([EMAIL PROTECTED]).removeAttr('disabled');
   }
 
 This way, you can even have the option of enforcing a minimum char length
 of
 the field/s.
 
 Michael
 
 
 It seems that submit method is not what this case requires because it
 does
 the job when user interacts with submit button (correct me please if I'm
 wrong). The button should be disabled if both field and textarea (now
 they
 are id's ;) do not contain any text, to prevent blank records. And the
 only
 event that might check contents of textareas and inputs seems to be
 keyup...
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Disable-Submit-button-if-no-text-entered-tp17226575s27240p17273665.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Disable Submit button if no text entered

2008-05-14 Thread andrea varnier

On 14 Mag, 11:01, sashabe [EMAIL PROTECTED] wrote:
 Hello!

hi :)
you'd better use the submit() method and 'return false'.
Then a quick solution to your problem could look like this:

$(document).ready(function(){
$('form').submit(function(){
if ($('input:first', 'form').val() == ''  $('textarea',
'form').val() == '') return false;
});
});

it would be better if you gave id's to the elements you're going to
check ;)


[jQuery] Re: Disable Submit button if no text entered

2008-05-14 Thread sashabe


Thank you! :)

It seems that submit method is not what this case requires because it does
the job when user interacts with submit button (correct me please if I'm
wrong). The button should be disabled if both field and textarea (now they
are id's ;) do not contain any text, to prevent blank records. And the only
event that might check contents of textareas and inputs seems to be keyup...

I've used your script to write this:

JQuery: 

$('#post_submit').attr('disabled', 'disabled');
$('#post_form').keyup( function () {
if ($('#post_name', '#post_form').val() == ''  $('#post_content',
'#post_form').text() == '') $('#post_submit').attr('disabled', 'disabled');
else ($('#post_submit', '#post_form').removeAttr('disabled'));
}); 

HTML:

form action=admin_content.php method=post id=post_form
input type=text name=name size=50 maxlength=100 
id=post_name
textarea name=content cols=70 rows=20
id=post_content?=$row[content];?/textarea
input type=Submit value=Отправить id=post_submit
/form

Now textarea does work (text() did the trick) - that is, submit button is
not activated when text is entered only there. But still, if you enter text
only in the text field (#post_name), it IS activated. And i want let the
user press it only when both fields are populated with at least one symbol
of text.

Please help)



Andrea Varnier wrote:
 
 
 On 14 Mag, 11:01, sashabe [EMAIL PROTECTED] wrote:
 Hello!
 
 hi :)
 you'd better use the submit() method and 'return false'.
 Then a quick solution to your problem could look like this:
 
 $(document).ready(function(){
 $('form').submit(function(){
 if ($('input:first', 'form').val() == ''  $('textarea',
 'form').val() == '') return false;
 });
 });
 
 it would be better if you gave id's to the elements you're going to
 check ;)
 
 

-- 
View this message in context: 
http://www.nabble.com/Disable-Submit-button-if-no-text-entered-tp17226575s27240p17232479.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Disable Submit button if no text entered

2008-05-14 Thread Dave Methvin

 $('#post_submit').attr('disabled', 'disabled');
 $('#post_form').keyup( function () {
 if ($('#post_name', '#post_form').val() == ''  $('#post_content',
 '#post_form').text() == '') $('#post_submit').attr('disabled', 'disabled');
 else ($('#post_submit', '#post_form').removeAttr('disabled'));
 });

I think this would work. The disabled attribute can be set to a true/
false value in script. Since keyup can be an expensive thing, I just
attached handlers to the two fields you needed to monitor rather than
the whole form; you could attach it to the form if you prefer. Rather
than set the initial value, I just triggered the handler to do its
thing on the initial form values. I wasn't sure why you used .text()
instead of .val() for the textarea, is there some kind of bug
in .val() for textarea? Also, remember that any post content (even a
bunch of spaces) will pass this test. You might want to do a bit more
validation on the input if it's important to the page.

$('#post_name, #post_content').keyup( function () {
$('#post_submit').attr('disabled', !$('#post_name').val()  || !$
('#post_content').val() );
}).trigger(keyup);


[jQuery] Re: Disable Submit button if no text entered

2008-05-14 Thread sashabe


Thanks!!! That's exactly what I wanted =)
Don't know if it's a bug, but with val entering some text in textarea with
blank name field activated the button. With text() it stopped to do so. And,
as I've read from some of the messages, text() could be more effective when
dealing with textarea content.


dave.methvin wrote:
 
 
 $('#post_submit').attr('disabled', 'disabled');
 $('#post_form').keyup( function () {
 if ($('#post_name', '#post_form').val() == '' 
 $('#post_content',
 '#post_form').text() == '') $('#post_submit').attr('disabled',
 'disabled');
 else ($('#post_submit', '#post_form').removeAttr('disabled'));
 });
 
 I think this would work. The disabled attribute can be set to a true/
 false value in script. Since keyup can be an expensive thing, I just
 attached handlers to the two fields you needed to monitor rather than
 the whole form; you could attach it to the form if you prefer. Rather
 than set the initial value, I just triggered the handler to do its
 thing on the initial form values. I wasn't sure why you used .text()
 instead of .val() for the textarea, is there some kind of bug
 in .val() for textarea? Also, remember that any post content (even a
 bunch of spaces) will pass this test. You might want to do a bit more
 validation on the input if it's important to the page.
 
 $('#post_name, #post_content').keyup( function () {
 $('#post_submit').attr('disabled', !$('#post_name').val()  || !$
 ('#post_content').val() );
 }).trigger(keyup);
 
 

-- 
View this message in context: 
http://www.nabble.com/Disable-Submit-button-if-no-text-entered-tp17226575s27240p17237539.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Disable Submit button if no text entered

2008-05-14 Thread Michael E. Carluen

Another suggestion will be to get the length of the field:

var t = ($('#post_name').val()).length;
if (t  0) {
$([EMAIL PROTECTED]).removeAttr('disabled');
}

This way, you can even have the option of enforcing a minimum char length of
the field/s.

Michael


 It seems that submit method is not what this case requires because it does
 the job when user interacts with submit button (correct me please if I'm
 wrong). The button should be disabled if both field and textarea (now they
 are id's ;) do not contain any text, to prevent blank records. And the
 only
 event that might check contents of textareas and inputs seems to be
 keyup...