[jQuery] Re: validation plugin addMethod does not work for me.
Still no go... below is my code. I just want to pop a dialog to ask the user if they are sure they want to leave the company name blank. The field is not required. I thought it would be easier than this? I can't get teh addMethod to work or fire at all on validation. //validates the form var validator = frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror', rules: { restitutionaddress: {required: #sameAsBusinessAddress [checked='false']}, restitutioncity: {required: #sameAsBusinessAddress [checked='false']}, restitutionstate: {required: #sameAsBusinessAddress [checked='false']}, restitutionzipcode: {required: #sameAsBusinessAddress [checked='false']}, company:true } }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name ); On Oct 21, 9:18 pm, Leonardo K leo...@gmail.com wrote: U need set the rules for your validation: frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) { error.prependTo( element.parents(div.ctrlHolder)); }, errorElement:'div', errorClass:'valerror', rules:{ nameField:{ company:true } } }); On Wed, Oct 21, 2009 at 22:04, JMan jbeck...@gmail.com wrote: what am I doing wrong here? I cannot figure out how to use the addMethod(). var frmSubmittal = $(#frmSubmittal); //validates the form frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror' }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name );
[jQuery] Re: validation plugin addMethod does not work for me.
One thing is your method name and other is your field name. If the name of your field is company and your method is company so: rules:{ company:{ company:true } } Maybe is better rename your method to not confuse. On Thu, Oct 22, 2009 at 13:24, JMan jbeck...@gmail.com wrote: Still no go... below is my code. I just want to pop a dialog to ask the user if they are sure they want to leave the company name blank. The field is not required. I thought it would be easier than this? I can't get teh addMethod to work or fire at all on validation. //validates the form var validator = frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror', rules: { restitutionaddress: {required: #sameAsBusinessAddress [checked='false']}, restitutioncity: {required: #sameAsBusinessAddress [checked='false']}, restitutionstate: {required: #sameAsBusinessAddress [checked='false']}, restitutionzipcode: {required: #sameAsBusinessAddress [checked='false']}, company:true } }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name ); On Oct 21, 9:18 pm, Leonardo K leo...@gmail.com wrote: U need set the rules for your validation: frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) { error.prependTo( element.parents(div.ctrlHolder)); }, errorElement:'div', errorClass:'valerror', rules:{ nameField:{ company:true } } }); On Wed, Oct 21, 2009 at 22:04, JMan jbeck...@gmail.com wrote: what am I doing wrong here? I cannot figure out how to use the addMethod(). var frmSubmittal = $(#frmSubmittal); //validates the form frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror' }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name );
[jQuery] Re: validation plugin addMethod does not work for me.
Thanks Leonardo... I figured it out after digging through several examples. The documentation for this plugin has a huge gap in it. It shows an example of how to define a custom validator but no where does it explain how to use it. The trick being as you mentioned, defining it in the Rules or you can put the name of your custom validator in the class attribute of the field it applies to. The sad part is after hours of struggling with this it does not work as I had hoped it would. I am prompting the user for input and based on their response I would like to either cancel the form submit or allow it to continue. On Oct 22, 11:48 am, Leonardo K leo...@gmail.com wrote: One thing is your method name and other is your field name. If the name of your field is company and your method is company so: rules:{ company:{ company:true } } Maybe is better rename your method to not confuse. On Thu, Oct 22, 2009 at 13:24, JMan jbeck...@gmail.com wrote: Still no go... below is my code. I just want to pop a dialog to ask the user if they are sure they want to leave the company name blank. The field is not required. I thought it would be easier than this? I can't get teh addMethod to work or fire at all on validation. //validates the form var validator = frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror', rules: { restitutionaddress: {required: #sameAsBusinessAddress [checked='false']}, restitutioncity: {required: #sameAsBusinessAddress [checked='false']}, restitutionstate: {required: #sameAsBusinessAddress [checked='false']}, restitutionzipcode: {required: #sameAsBusinessAddress [checked='false']}, company:true } }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name ); On Oct 21, 9:18 pm, Leonardo K leo...@gmail.com wrote: U need set the rules for your validation: frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) { error.prependTo( element.parents(div.ctrlHolder)); }, errorElement:'div', errorClass:'valerror', rules:{ nameField:{ company:true } } }); On Wed, Oct 21, 2009 at 22:04, JMan jbeck...@gmail.com wrote: what am I doing wrong here? I cannot figure out how to use the addMethod(). var frmSubmittal = $(#frmSubmittal); //validates the form frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror' }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name );
[jQuery] Re: validation plugin addMethod does not work for me.
U need set the rules for your validation: frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) { error.prependTo( element.parents(div.ctrlHolder)); }, errorElement:'div', errorClass:'valerror', rules:{ nameField:{ company:true } } }); On Wed, Oct 21, 2009 at 22:04, JMan jbeck...@gmail.com wrote: what am I doing wrong here? I cannot figure out how to use the addMethod(). var frmSubmittal = $(#frmSubmittal); //validates the form frmSubmittal.validate({ debug: false, focusCleanup: false, focusInvalid: false, onfocusout: false, onkeyup: false, errorPlacement: function(error, element) {error.prependTo ( element.parents(div.ctrlHolder));}, errorElement:'div', errorClass:'valerror' }); $.validator.addMethod( company, function(value, element) {alert (hello); return false;}, Enter a Company Name );