[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread ciupaz
I have created the file jquery.validateCopy.js and added with: in my HEAD section. Than I write: jQuery.validator.addMethod("GetValue", function() { return true; }, jQuery.format("Please enter the correct value")); in it. Then I modify it with: city: { required: GetV

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread Jörn Zaefferer
Nope, just add the code in some file, included after jquery.validate.js. Jörn On Tue, May 26, 2009 at 4:03 PM, ciupaz wrote: > > I must write it in the jquery.validate.js file?

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread ciupaz
I must write it in the jquery.validate.js file?

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread Jörn Zaefferer
Custom methods are documented here: http://docs.jquery.com/Plugins/Validation/Validator/addMethod Jörn On Tue, May 26, 2009 at 3:49 PM, ciupaz wrote: > > Yes, exactly, and I'm trying this custom method: > > function GetCityValue() { >        var value = $('#city').val(); >        if (value == -

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread ciupaz
Yes, exactly, and I'm trying this custom method: function GetCityValue() { var value = $('#city').val(); if (value == -1) { return true; } else { return false; } } and .. city: { required: GetCityValue()

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread Jörn Zaefferer
You'd have to write a custom method for that. Or replace the value on submit or something like that. The required-rule works with an empty value. Jörn On Tue, May 26, 2009 at 3:22 PM, ciupaz wrote: > > Thank you Jorn, now with the "name" attribute it's working. > A simple question. > For busine

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread ciupaz
Thank you Jorn, now with the "name" attribute it's working. A simple question. For business rules I have to give the value "-1" to the "Select the city" option. Like this: Select a city Milan Turin Rome

[jQuery] Re: Validate selectedValue in a combobox

2009-05-26 Thread Jörn Zaefferer
The validation plugin uses the name-attribute. Your select has just an id, no name. Add name="city" and it should be working! Jörn On Tue, May 26, 2009 at 2:20 PM, ciupaz wrote: > > Hi all, > I have a simple combobox like this: > > > >                    Select a city >                    Mila