Validate a single field

3 messages Options
Embed this post
Permalink
Dave-33

Validate a single field

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
How can I validate a single field using Ajax?
 
I am attempting to use jquery remote feature to check fields for validity. But its checking the entire model and reporting fields that have not had data entered. If a form has 3 fields and the user types into the second field for example i only want to check if that field is valid, not the entire form.
 
I am trying to validate an email to start off with so data[Profile][email] =  [hidden email] gets sent to cake to validate
 
How can I validate only Profile.email? I want to use the same function eventually to validate other fields so i do not want to hard code 'email' into the function. Is there a way to get the field name [email] as a variable and then validate just that rule in the model and return a true or false?
 
Thanks
 
Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

euromark (munich)

Re: Validate a single field

Reply Threaded More More options
Print post
Permalink

just submit only that field

the model validation is only triggered for fields that are beeing
passed
so if there is only one passed form field, only this one will be
validated

PS: dont use "required''=>true" in your rules or you screw it up


On 7 Nov., 17:43, "Dave" <[hidden email]> wrote:

> How can I validate a single field using Ajax?
>
> I am attempting to use jquery remote feature to check fields for validity.
> But its checking the entire model and reporting fields that have not had
> data entered. If a form has 3 fields and the user types into the second
> field for example i only want to check if that field is valid, not the
> entire form.
>
> I am trying to validate an email to start off with so data[Profile][email] =
> [hidden email] gets sent to cake to validate
>
> How can I validate only Profile.email? I want to use the same function
> eventually to validate other fields so i do not want to hard code 'email'
> into the function. Is there a way to get the field name [email] as a
> variable and then validate just that rule in the model and return a true or
> false?
>
> Thanks
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Dave-33

RE: Validate a single field

Reply Threaded More More options
Print post
Permalink

I am getting closer but still no message shows up in the form.

I get the error div appearing but no message.
The response sent to the page looks like:

FIREFOX JSON TAB:

{"valid":false,"data[Profile][email]":{"messages":{"remote":"from cake"}}}

I will worry about the actual cake error message later so I just hard coded
"from cake" to see if it shows up but I get no message ever. If its valid
the error div still shows up.

I modified my validate options so they now look like:

var validate_options = {
        rules: {

                        "data[Profile][email]":{remote: {url:
"/manage/profiles/validate",type: "post", data: {fieldname: 'email'}}},

        },
        messages: {
                        }
                         
};

Any ideas how why my messages: are not papering or why it error div appears
when valid?

Any help or suggestions would be great.

Thanks

Dave

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf
Of euromark (munich)
Sent: November-07-09 1:56 PM
To: CakePHP
Subject: Re: Validate a single field


just submit only that field

the model validation is only triggered for fields that are beeing passed so
if there is only one passed form field, only this one will be validated

PS: dont use "required''=>true" in your rules or you screw it up


On 7 Nov., 17:43, "Dave" <[hidden email]> wrote:

> How can I validate a single field using Ajax?
>
> I am attempting to use jquery remote feature to check fields for validity.
> But its checking the entire model and reporting fields that have not
> had data entered. If a form has 3 fields and the user types into the
> second field for example i only want to check if that field is valid,
> not the entire form.
>
> I am trying to validate an email to start off with so
> data[Profile][email] = [hidden email] gets sent to cake to
> validate
>
> How can I validate only Profile.email? I want to use the same function
> eventually to validate other fields so i do not want to hard code 'email'
> into the function. Is there a way to get the field name [email] as a
> variable and then validate just that rule in the model and return a
> true or false?
>
> Thanks
>
> Dave


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---