[jQuery] Re: How to remove error messages from Validation Plugin
Here is an interesting way to do it. In my case, I was using a main error div at the top of the page, so I didn't need the individual label.error elements inline. They kept showing up no matter what I did until I added this to my validation: errorElement: em This changes the element that the errors are displayed in from label to em. I am not using any em elements on my page, so the error messages just don't show up (except the main one, which I want to show up). jQuery.validator.messages.required = ; $('#member_form').validate({ //change error element errorElement: em, //use main error div instead invalidHandler: function(e, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted below' : 'You missed ' + errors + ' fields. They have been highlighted below'; $(div.error span).html(message); $(div.error).show(); } else { $(div.error).hide(); } }, rules: { username: { required: true, email: true }, password: { required: true, minlength: 4, maxlength: 10 }, password_confirm: { required: true, equalTo: #password, minlength: 4, maxlength: 10 }, accept_terms: required, cf_member_fname: required, cf_member_lname: required, cf_member_city: required, cf_member_country: required, captcha: required } }); On Apr 10, 8:08 pm, Rick r...@marketingease.com wrote: I'm using this plugin in its simplest form..http://docs.jquery.com/Plugins/Validation All I have is this for my code: script $(document).ready(function(){ $(#form).validate();}); /script It works fine, but I'm trying to hide the error messages which it defaults to This field is required. The error message shows up in a label.. How in the world do I hide those error messages within those labels??? I'm sure it's easy, but I cannot find any examples anywhere!! Thanks to whoever helps out..
[jQuery] Spammer bypassing JQ Validate to register?
I have a site built in ExpressionEngine. I am using JQ Validate to check the form fields before submission. There are 3 fields in particular that are interesting to me as they are required by EE and they are on the list of fields required by JQ Validate. First Name Last Name Invitation Code (provided by the site owner to visitors who can register) So, this dude from Poland managed to register without a first name, without a last name and likely without an invitation code. I'll deal with the EE issues separately, but is there a known issue where someone can mess with the jquery in the page to bypass the validation that is running?
[jQuery] Re: validate : help with required code
I understand that, I am asking for help writing that custom method. I can't get it to work. So, if name_first = First then its required, if it is anything else it is valid. Thanks On Nov 7, 4:48 am, Jörn Zaefferer [EMAIL PROTECTED] wrote: In this case you need a custom required-method. Your check makes the field required, but its still valid to the required method (it has a value). Jörn On Thu, Nov 6, 2008 at 6:45 PM, Chuck Cheeze [EMAIL PROTECTED] wrote: I have a form field that by default has the value First. When the user clicks into the field it clears that value, and if they type nothing, when they blur the field it replaces First. You've all seen this. I want the validate plugin to say this field is required if the value onsubmit is First. Can't seem to make it work. [code] // validate signup form on keyup and submit $(#contactform).validate({ rules: { name_first: { required: function(element) { return $ ('#name_first').val() != First; } }, name_last: required, country: required, otherinfo: required, email: { required: true, email: true } } }); input type=text name=name_first value=First size=15 id=name_first class=inputfield_name swaptextbox greybox tabindex=1 / [/code] Once I do that, I'll use the same code for last name.
[jQuery] [validate] Help with required code
I have a form field that by default has the value First. When the user clicks into the field it clears that value, and if they type nothing, when they blur the field it replaces First. You've all seen this. I want the validate plugin to say this field is required if the value onsubmit is First. Can't seem to make it work. [code] // validate signup form on keyup and submit $(#contactform).validate({ rules: { name_first: { required: function(element) { return $('#name_first').val() != First; } }, name_last: required, country: required, otherinfo: required, email: { required: true, email: true } } }); input type=text name=name_first value=First size=15 id=name_first class=inputfield_name swaptextbox greybox tabindex=1 / [/code] Once I do that, I'll use the same code for last name.
[jQuery] validate : help with required code
I have a form field that by default has the value First. When the user clicks into the field it clears that value, and if they type nothing, when they blur the field it replaces First. You've all seen this. I want the validate plugin to say this field is required if the value onsubmit is First. Can't seem to make it work. [code] // validate signup form on keyup and submit $(#contactform).validate({ rules: { name_first: { required: function(element) { return $ ('#name_first').val() != First; } }, name_last: required, country: required, otherinfo: required, email: { required: true, email: true } } }); input type=text name=name_first value=First size=15 id=name_first class=inputfield_name swaptextbox greybox tabindex=1 / [/code] Once I do that, I'll use the same code for last name.
[jQuery] Help writing function for sending a serialized post for updating a UL order
I have a UL: ul id=child_list li id=item_1One/li li id=item_2Two/li li id=item_3Three/li /ul I have a function: $(document).ready(function() { //sortables $(#child_list).sortable({ opacity: 0.7, revert: true, scroll: true, handle: $(.handle), change: function(sorted){ $.post(/admin/ajax/orderChildren.asp, { item_order_str: $ ('#child_list').sortable(serialize) }); }); I am switching this over from scriptaculous, and I need to know if the above is written correctly, and also, what would the data posted to the orderChildren.asp page look like, and how would I access the variable on that page?
[jQuery] IE Issues with addClass/removeClass
www.webinception.com On the homepage of my site I use jQuery to dynamically remove a class and add a class to the 3rd div box under Recent Projects. What this does is allow the floated boxes to all line up on a single row by removing the default class for this box and add in an identical class that has a margin-right:0 rule. Since these boxes are built dynamically by ExpressionEngine this was my way to remove the right side margin. In IE7 and IE6 what is happening is that the DOM is loaded in with that 3rd box on a second row, then jQuery loads in the new class and all layout items under the box shift up, which includes the footer background. However, the footer P tags aren't shifting up. Any ideas?
[jQuery] Help with selecting great grandchildren
Below is my html/EE code: pre div class=less-info !-- Standard configuration -- !-- Show more button -- span class=show-more{lang_showmoreinfo}/span !-- Standard configuration tab -- span class=tab{lang_standardconfigurations}/span !-- Parts list -- ul class=part-detail-box {related_entries id=cf_products_parts} !-- loop -- li class=line-item !-- Part number - floated right -- span class=part-number{cf_parts_partnumber}/span !-- Part title - aligned left -- {cf_parts_title} {if cf_parts_desc} div class=line-item-detail {cf_parts_desc} /div {/if} /li {/related_entries} !-- end loop -- /ul !-- part-detail-box -- /div !-- less-info -- /pre What I want is for the user to click the span.show-more and have it toggle show/hide all li.line-item's within its own parent (div.less- info). I tried all types of stuff. I can get the parent to show/ hide, so I can get that far. From there I need to get to all child li.line-items. Here is what i stopped with, which I know is incorrect snce children() only selects direct children: pre //toggle the display of the individual product details $(.show-more).toggle( function() { $(this).parent().children(.line-item).show(); }, function() { $(this).parent().children(.line-item).hide(); } ); /pre
[jQuery] Re: Help with selecting great grandchildren
Perfect thanks. Not sure why I couldn't get that going myself... On May 2, 2:32 pm, BlueCockatoo [EMAIL PROTECTED] wrote: You could use $(.line-item, $(this).parent()) which brings back all .line-items under the context of the parent or you could use $(this).parent().find(.line-item) which searches for any .line-items under the parent. Either one should work, so pick your favorite :) - Lindsay On May 2, 12:38 pm, Chuck Cheeze [EMAIL PROTECTED] wrote: Below is my html/EE code: pre div class=less-info !-- Standard configuration -- !-- Show more button -- span class=show-more{lang_showmoreinfo}/span !-- Standard configuration tab -- span class=tab{lang_standardconfigurations}/span !-- Parts list -- ul class=part-detail-box {related_entries id=cf_products_parts} !-- loop -- li class=line-item !-- Part number - floated right -- span class=part-number{cf_parts_partnumber}/span !-- Part title - aligned left -- {cf_parts_title} {if cf_parts_desc} div class=line-item-detail {cf_parts_desc} /div {/if} /li {/related_entries} !-- end loop -- /ul !-- part-detail-box -- /div !-- less-info -- /pre What I want is for the user to click the span.show-more and have it toggle show/hide all li.line-item's within its own parent (div.less- info). I tried all types of stuff. I can get the parent to show/ hide, so I can get that far. From there I need to get to all child li.line-items. Here is what i stopped with, which I know is incorrect snce children() only selects direct children: pre //toggle the display of the individual product details $(.show-more).toggle( function() { $(this).parent().children(.line-item).show(); }, function() { $(this).parent().children(.line-item).hide(); } ); /pre
[jQuery] Re: Having trouble with += and toFixed for some reason
Thanks alot - i've never been good with javascript... worked great. On Apr 4, 3:01 pm, Wizzud [EMAIL PROTECTED] wrote: Initialise as numbers instead of strings?... var bagqty = 0; var bagtotal = 0; On Apr 4, 9:35 pm, Chuck Cheeze [EMAIL PROTECTED] wrote: Here is my code: pre script type=text/javascript //on page load $(document).ready(function() { //add up the cart totals and display on the page //setup default values var bagqty = ''; var bagtotal = ''; //get all table rows $('#shoppingcart tbody tr').each(function() { //get the row's price, remove the $ var price = parseFloat($('.itemprice', this).text().replace(/^[^ \d.]*/, '')); //make sure its a number price = isNaN(price) ? 0 : price; //get the row's quantity var qty = parseInt($('.itemqty', this).text()); //get the item's shipping amount var ship = parseFloat($('.itemshipping', this).text().replace(/^[^ \d.]*/, '')); //make sure its a number ship = isNaN(ship) ? 0 : ship; //calculate the extended price var extprice = (qty * price) + ship; //add back in the $ sign and write to the page $('.itemextprice', this).text('$' + extprice.toFixed(2)); //add to totals bagqty += qty; bagtotal += extprice; }); //return the totals $('.bagtotal').text('$' + bagtotal.toFixed(2)); }); /script /pre I have 2 issues- 1- the bagqty += qty; and bagtotal += extprice; calculations return appended values, not added. So if there are 2 products and the bagqty values are 5 and 3 I get 53 instead of 8. 2- the $('.bagtotal').text('$' + bagtotal); line won't work. I get a bagtotal.toFixed is not a function error. It works fine in the itemextprize calculation up higher. Any ideas?
[jQuery] Having trouble with += and toFixed for some reason
Here is my code: pre script type=text/javascript //on page load $(document).ready(function() { //add up the cart totals and display on the page //setup default values var bagqty = ''; var bagtotal= ''; //get all table rows $('#shoppingcart tbody tr').each(function() { //get the row's price, remove the $ var price = parseFloat($('.itemprice', this).text().replace(/^[^ \d.]*/, '')); //make sure its a number price = isNaN(price) ? 0 : price; //get the row's quantity var qty = parseInt($('.itemqty', this).text()); //get the item's shipping amount var ship = parseFloat($('.itemshipping', this).text().replace(/^[^ \d.]*/, '')); //make sure its a number ship = isNaN(ship) ? 0 : ship; //calculate the extended price var extprice = (qty * price) + ship; //add back in the $ sign and write to the page $('.itemextprice', this).text('$' + extprice.toFixed(2)); //add to totals bagqty += qty; bagtotal += extprice; }); //return the totals $('.bagtotal').text('$' + bagtotal.toFixed(2)); }); /script /pre I have 2 issues- 1- the bagqty += qty; and bagtotal += extprice; calculations return appended values, not added. So if there are 2 products and the bagqty values are 5 and 3 I get 53 instead of 8. 2- the $('.bagtotal').text('$' + bagtotal); line won't work. I get a bagtotal.toFixed is not a function error. It works fine in the itemextprize calculation up higher. Any ideas?