[jQuery] Re: Conditional required fields
I fixed the problem. It was this method: var autoHide = function() { memberSections.find('.section').hideExtras(memberCount.val()); youngerSections.find('.section').hideExtras(youngerMemberCount.val ()); } I changed it to: var autoHide = function() { if(!$('#memberless input').is(':checked')) { memberSections.find('.section').hideExtras(memberCount.val()); } if(!$('#younger-memberless input').is(':checked')) { youngerSections.find('.section').hideExtras (youngerMemberCount.val()); } } So that the field validators would not be added back when the individual sections were excluded. Thomas On Apr 30, 2:16 pm, Thomas Allen thomasmal...@gmail.com wrote: Thanks. I ended up using the classes add/remove style, and it works well. However, a method that should be called on every page load is not working properly. I am sure that it's being called (tested with the console), but the removeValidators() method doesn't seem to work properly. http://content.constructioninst.org/corporate_renewal.html On every page load, removeValidators will be called, which removes the required and email validation classes found within the jQuery object of the selector (first arg) if the caller's checkbox is checked. The problem is if, for example, I fill out the first section with its required fields, check the first box (which hides the bulk of the form), choose Check for payment, and submit. If I go back, while the hide/removeValidator method (membersUnnecessary) is called and does indicate that the checkbox is checked (the same sections are hidden), I cannot re-submit the form: The validation classes are not removed. What can I do to fix this? I know that the code's a bit clumsy, but I can explain any specific parts if needed. Thanks, Thomas
[jQuery] Re: Conditional required fields
Thanks. I ended up using the classes add/remove style, and it works well. However, a method that should be called on every page load is not working properly. I am sure that it's being called (tested with the console), but the removeValidators() method doesn't seem to work properly. http://content.constructioninst.org/corporate_renewal.html On every page load, removeValidators will be called, which removes the required and email validation classes found within the jQuery object of the selector (first arg) if the caller's checkbox is checked. The problem is if, for example, I fill out the first section with its required fields, check the first box (which hides the bulk of the form), choose Check for payment, and submit. If I go back, while the hide/removeValidator method (membersUnnecessary) is called and does indicate that the checkbox is checked (the same sections are hidden), I cannot re-submit the form: The validation classes are not removed. What can I do to fix this? I know that the code's a bit clumsy, but I can explain any specific parts if needed. Thanks, Thomas
[jQuery] [validate] Conditional required fields
I have a form with a flexible number of field sets on my form. I think it'll be easier to understand if you just fiddle around a bit here: http://content.constructioninst.org/corporate_renewal.html I want to make a handful of fields be required in each field set, but only fields in visible field sets should be required. I have a mechanism to check this; the toggler I created updates a hidden field when a set is added or removed (there is one such counter field for each expandable section, Individual Members and Younger Members. Should I simply add the required class to the appropriate inputs in a field set when it's exposed, and remove them when hidden? Seems a little hackish, but maybe that's the best way. Also, if anybody has pointers for the script that's there, that would be nice :^) One thing that I still have to do is make the field set counts visible to the user, but that's more of a design question right now. Thanks, Thomas
[jQuery] Re: [validate] Conditional required fields
a custom method is used for the fields inside the Billing Address group What does this method do (or, better, what's it called so I can search the source)? Thanks, Thomas On Apr 28, 2:16 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote: One alternative approach can be found here:http://jquery.bassistance.de/validate/demo/marketo/step2.htm Instead of adding and removing classes, a custom method is used for the fields inside the Billing Address group. Whatever works for you... Jörn On Tue, Apr 28, 2009 at 7:20 PM, Thomas Allen thomasmal...@gmail.com wrote: I have a form with a flexible number of field sets on my form. I think it'll be easier to understand if you just fiddle around a bit here: http://content.constructioninst.org/corporate_renewal.html I want to make a handful of fields be required in each field set, but only fields in visible field sets should be required. I have a mechanism to check this; the toggler I created updates a hidden field when a set is added or removed (there is one such counter field for each expandable section, Individual Members and Younger Members. Should I simply add the required class to the appropriate inputs in a field set when it's exposed, and remove them when hidden? Seems a little hackish, but maybe that's the best way. Also, if anybody has pointers for the script that's there, that would be nice :^) One thing that I still have to do is make the field set counts visible to the user, but that's more of a design question right now. Thanks, Thomas
[jQuery] Re: Conditional required fields
And I'm not going out of my way to change the subject...I'm not sure what's going on there. Thomas On Apr 28, 2:40 pm, Thomas Allen thomasmal...@gmail.com wrote: a custom method is used for the fields inside the Billing Address group What does this method do (or, better, what's it called so I can search the source)? Thanks, Thomas On Apr 28, 2:16 pm, Jörn Zaefferer joern.zaeffe...@googlemail.com wrote: One alternative approach can be found here:http://jquery.bassistance.de/validate/demo/marketo/step2.htm Instead of adding and removing classes, a custom method is used for the fields inside the Billing Address group. Whatever works for you... Jörn On Tue, Apr 28, 2009 at 7:20 PM, Thomas Allen thomasmal...@gmail.com wrote: I have a form with a flexible number of field sets on my form. I think it'll be easier to understand if you just fiddle around a bit here: http://content.constructioninst.org/corporate_renewal.html I want to make a handful of fields be required in each field set, but only fields in visible field sets should be required. I have a mechanism to check this; the toggler I created updates a hidden field when a set is added or removed (there is one such counter field for each expandable section, Individual Members and Younger Members. Should I simply add the required class to the appropriate inputs in a field set when it's exposed, and remove them when hidden? Seems a little hackish, but maybe that's the best way. Also, if anybody has pointers for the script that's there, that would be nice :^) One thing that I still have to do is make the field set counts visible to the user, but that's more of a design question right now. Thanks, Thomas
[jQuery] Re: Do object events persist in cloning? I can't get this method to work.
Yep, that did it, thanks. I had never heard of this before. Thomas On Apr 27, 10:13 am, Scott Sauyet li...@sauyet.com wrote: Thomas Allen wrote: What I'm doing is creating a couple button objects and cloning them. $(memberSections).prepend(toggler.clone()); $(youngerSections).prepend(toggler.clone()); }); Why is it that neither button logs to the console when clicked? You might try passing true to the clone method. [1] That copies event handlers as well. I don't know if it will solve your problem, but it's worth a try. Cheers, -- Scott [1]http://docs.jquery.com/Clone#clone.28.C2.A0bool_.29
[jQuery] Re: Plugin does not bind to jQuery object
That was it. jQuery was being loaded just before /body, so it was overwriting the jQuery object loaded earlier (via the custom page). By moving this to the top and deleting the extra script reference, I fixed the problem. Thanks! Thomas On Apr 16, 12:37 am, Thomas Allen thomasmal...@gmail.com wrote: This is possible, and makes sense. I'll take a look tomorrow (the main template for this site includes jQuery, and we include these scripts on forms, which is where things got mixed up). Thomas On Apr 15, 4:55 pm, Eric Garside gars...@gmail.com wrote: Upon further inspection, I'm not quite sure what to make of your page. Firebug's Net console reported the following includes in the following order: 1. jquery-1.3.2.js 2. jquery.validate.min.js 3. validate-common.js 4. asce03.js 5. validate.js 6. jquery-1.2.6.js 7. jquery-dropdown-menus.js So, for one reason or another, you're including 2 different versions of jQuery on the same page. I'm not sure if that's causing the issue, but I can't imagine it's useful or efficient. I'd check into that as a first-line of defense. Removing the older jQuery version might fix it? On Apr 15, 4:44 pm, Thomas Allen thomasmal...@gmail.com wrote: No, that's not it. The scripts are ordered: script src=/lib/javascript/jquery-1.3.2.js type=text/javascript/ script script src=/lib/javascript/jquery.validate.min.js type=text/ javascript/script Which is why only one exception is thrown. If I flip the order of those two, two exceptions are thrown, one for the missing jQuery object, and another for the validate method. Ignore the reference to validate.js in the head, that's not being used here. Thomas On Apr 15, 4:39 pm, Eric Garside gars...@gmail.com wrote: It's the order of your includes. In the first page, you're including the validation plugin before you're including jQuery. The result is that, when validation attempts to enter itself into the jQuery namespace, jQuery is undefined, so it just dies within it's enclosure. On Apr 15, 4:30 pm, Thomas Allen thomasmal...@gmail.com wrote: These two pages do the exact same thing: Apply some basic validation rules to a form. The only difference is that the first one includes the scripts in body, not head. 1.http://www.asce.org/freemembership/ 2.http://content.asce.org/conferences/texasstudentdays/company_registra... The second one works, and the first doesn't. For some reason, the first site doesn't bind the validate method to jQuery. $.fn.validate() throws an exception in the console. What's going on, and how can I fix this problem? The file itself is definitely being loaded. Thanks, Thomas
[jQuery] Plugin does not bind to jQuery object
These two pages do the exact same thing: Apply some basic validation rules to a form. The only difference is that the first one includes the scripts in body, not head. 1. http://www.asce.org/freemembership/ 2. http://content.asce.org/conferences/texasstudentdays/company_registration.html The second one works, and the first doesn't. For some reason, the first site doesn't bind the validate method to jQuery. $.fn.validate() throws an exception in the console. What's going on, and how can I fix this problem? The file itself is definitely being loaded. Thanks, Thomas
[jQuery] Re: Plugin does not bind to jQuery object
No, that's not it. The scripts are ordered: script src=/lib/javascript/jquery-1.3.2.js type=text/javascript/ script script src=/lib/javascript/jquery.validate.min.js type=text/ javascript/script Which is why only one exception is thrown. If I flip the order of those two, two exceptions are thrown, one for the missing jQuery object, and another for the validate method. Ignore the reference to validate.js in the head, that's not being used here. Thomas On Apr 15, 4:39 pm, Eric Garside gars...@gmail.com wrote: It's the order of your includes. In the first page, you're including the validation plugin before you're including jQuery. The result is that, when validation attempts to enter itself into the jQuery namespace, jQuery is undefined, so it just dies within it's enclosure. On Apr 15, 4:30 pm, Thomas Allen thomasmal...@gmail.com wrote: These two pages do the exact same thing: Apply some basic validation rules to a form. The only difference is that the first one includes the scripts in body, not head. 1.http://www.asce.org/freemembership/ 2.http://content.asce.org/conferences/texasstudentdays/company_registra... The second one works, and the first doesn't. For some reason, the first site doesn't bind the validate method to jQuery. $.fn.validate() throws an exception in the console. What's going on, and how can I fix this problem? The file itself is definitely being loaded. Thanks, Thomas
[jQuery] Re: Plugin does not bind to jQuery object
This is possible, and makes sense. I'll take a look tomorrow (the main template for this site includes jQuery, and we include these scripts on forms, which is where things got mixed up). Thomas On Apr 15, 4:55 pm, Eric Garside gars...@gmail.com wrote: Upon further inspection, I'm not quite sure what to make of your page. Firebug's Net console reported the following includes in the following order: 1. jquery-1.3.2.js 2. jquery.validate.min.js 3. validate-common.js 4. asce03.js 5. validate.js 6. jquery-1.2.6.js 7. jquery-dropdown-menus.js So, for one reason or another, you're including 2 different versions of jQuery on the same page. I'm not sure if that's causing the issue, but I can't imagine it's useful or efficient. I'd check into that as a first-line of defense. Removing the older jQuery version might fix it? On Apr 15, 4:44 pm, Thomas Allen thomasmal...@gmail.com wrote: No, that's not it. The scripts are ordered: script src=/lib/javascript/jquery-1.3.2.js type=text/javascript/ script script src=/lib/javascript/jquery.validate.min.js type=text/ javascript/script Which is why only one exception is thrown. If I flip the order of those two, two exceptions are thrown, one for the missing jQuery object, and another for the validate method. Ignore the reference to validate.js in the head, that's not being used here. Thomas On Apr 15, 4:39 pm, Eric Garside gars...@gmail.com wrote: It's the order of your includes. In the first page, you're including the validation plugin before you're including jQuery. The result is that, when validation attempts to enter itself into the jQuery namespace, jQuery is undefined, so it just dies within it's enclosure. On Apr 15, 4:30 pm, Thomas Allen thomasmal...@gmail.com wrote: These two pages do the exact same thing: Apply some basic validation rules to a form. The only difference is that the first one includes the scripts in body, not head. 1.http://www.asce.org/freemembership/ 2.http://content.asce.org/conferences/texasstudentdays/company_registra... The second one works, and the first doesn't. For some reason, the first site doesn't bind the validate method to jQuery. $.fn.validate() throws an exception in the console. What's going on, and how can I fix this problem? The file itself is definitely being loaded. Thanks, Thomas
[jQuery] Re: why i getting Error: form.ajaxSubmit is not a function
On Apr 9, 2:26 am, Hellofrom hellof...@gmail.com wrote: I try to use Form plug in with Validaiton plug in i get the following error if firefox Error: form.ajaxSubmit is not a function can someone help me please I'd like to. Could you please post your code that produces this error? Thomas
[jQuery] Re: IE display issue
On Apr 9, 8:16 am, Tim t...@timandnoelle.com wrote: i am setting reducing a tbody height when the user clicks a row and then showing content below the table. in IE7 when i show() or set display to block for the content below the table, IE resets the tbody height to the original size such that it overlaps my content. i've put the code in to reset the height again, but it doesn't do anything at that point. any ideas? Can we see your code? Thomas
[jQuery] Re: Is jquery safe ?
Oh, it gives you a virus...the virus of a clean API for the DOM. Some people in comp.lang.javascript would argue that jQuery itself is a virus, but they're a bit off-kilter. Thomas On Apr 9, 6:22 am, Devesh erdeveshmis...@gmail.com wrote: Hi, I am using the latest version of jquery. I want to confirm that is there any type virus or trozan with the latest version of jquery. I have searched it on google a lot, but not able to find any exact answer. Please confirm me. Thanks Devesh M
[jQuery] Terrible print styles in the docs
Printed documentation includes many superfluous elements and cuts off the right side of the page in certain browsers. I know CSS like the back of my hand; is there something I can do to correct this? I'd be happy to. http://docs.jquery.com/skins/common/commonPrint.css - Missing quite a bit Thomas
[jQuery] Re: Terrible print styles in the docs
Sure, I'll do that. Thomas On Apr 8, 2:02 pm, Ralph Whitbeck ralph.whitb...@gmail.com wrote: Thomas, You could submit a bug and if you want to help submit a patch to the bug and I am sure the team will consider it. Thanks, Ralph On Wed, Apr 8, 2009 at 1:50 PM, Thomas Allen thomasmal...@gmail.com wrote: Printed documentation includes many superfluous elements and cuts off the right side of the page in certain browsers. I know CSS like the back of my hand; is there something I can do to correct this? I'd be happy to. http://docs.jquery.com/skins/common/commonPrint.css- Missing quite a bit Thomas
[jQuery] A simple jQuery script that throws errors and fails in IE6-7. Thoughts?
What am I doing wrong here? I get an expected identifier sort of error with the following code: (function($) { $('.calendarInfo').hide(); $('#calendar-frontpage').prepend( $('a/a') .html('Show Calendar List') .attr('href', 'javascript:;'); .css({ 'display': 'block', 'text-align': 'right', }) .click(function() { if($(this).html()[0] == 'S') { // I know, this is grimy, but it works. $('.calendarInfo').show(); $(this).html('Hide Calendar List'); } else { $('.calendarInfo').hide(); $(this).html('Show Calendar List'); } }); ); }) (jQuery); Thanks, Thomas Allen
[jQuery] Re: A simple jQuery script that throws errors and fails in IE6-7. Thoughts?
Oh, I thought that was a recommended practice to reduce bugs when changing the number of items in an object. Thanks! Thomas On Mar 9, 9:58 am, pete higgins phigg...@gmail.com wrote: .css({ 'display': 'block', 'text-align': 'right', }) stray comma, after 'right' http://jslint.com Regards, Peter
[jQuery] The order of these conditions should not matter
Here's my JS: http://pastebin.com/m6091a365 And the accompanying HTML: http://pastebin.com/m30c57ea6 For some reason, the if($(pay_... condition that comes first gets overridden by the one that follows it. The :checked states you see in the JS are mutually exclusive because they are a part of the same radio group (as seen in the HTML). The showCC and showCheck functions work perfectly in the focus() context (they switch normally). The reason that I'm setting this up this way is so that a user will only see the payment region that they need to see. Thanks, Thomas Allen
[jQuery] Re: The order of these conditions should not matter
Good call; thanks! I've been working with the Validate plugin, and the depends guards appear to be creeping into my other code :^) Thomas On Feb 10, 2:41 pm, Ricardo Tomasi ricardob...@gmail.com wrote: Doh. I'm blind. $(#pay_cc:checked) will always be 'true'. even if the element is not found an object will be returned. You have to check for .length or size () if($(#pay_cc:checked).length) showCC(); if($(#pay_check:checked).length) showCheck(); cheers, - ricardo On Feb 10, 5:29 pm, Thomas Allen thomasmal...@gmail.com wrote: It works fine for the focus event. The purpose of the conditionals is to ensure that the correct payment field pops up if the page is reloaded/revisited. For whatever reason, on a page reload, showCheck() always fires, even line 1's condition returns true and line 2's returns false (I've tested this in Firebug's console, and the conditionals work fine when entered individually). if($(#pay_cc:checked)) showCC(); if($(#pay_check:checked)) showCheck(); This is very problematic. If I remove the second line, the first line works as expected, and I observe the same behavior when I try these conditionals reverse order (Check first, causing CC to always override it). Thomas On Feb 10, 2:23 pm, Ricardo Tomasi ricardob...@gmail.com wrote: What do you mean by overriden? Just copied your code over and it seems to work fine. http://jsbin.com/efejehttp://jsbin.com/efeje/edit - ricardo On Feb 10, 3:07 pm, Thomas Allen thomasmal...@gmail.com wrote: Here's my JS:http://pastebin.com/m6091a365 And the accompanying HTML:http://pastebin.com/m30c57ea6 For some reason, the if($(pay_... condition that comes first gets overridden by the one that follows it. The :checked states you see in the JS are mutually exclusive because they are a part of the same radio group (as seen in the HTML). The showCC and showCheck functions work perfectly in the focus() context (they switch normally). The reason that I'm setting this up this way is so that a user will only see the payment region that they need to see. Thanks, Thomas Allen