elclanrs / jq-idealforms-old

The ultimate framework for building and validating responsive HTML5 forms.
665 stars 95 forks source link

Can we SET field to valid / invalid? #109

Open aim12340 opened 11 years ago

aim12340 commented 11 years ago

Hi,

Is it possible from plain js to set afield to be valid/invalid? something like $myform.AField.IsValid = False

it looks like i can set the fields class in include either valid invalid or (neither) - field appears unvalidated.

i guess this will affect the appearance ok but i dont like bypassing idealforms like this - it could easily come back to bite me if i use undocumented stuff like this.

Cheers.

elclanrs commented 11 years ago

Depending on the field you can probably just set the value and trigger an event to validate it.

$('#myinput').val('Hello').trigger('focus');

See if that helps...

aim12340 commented 11 years ago

Thanks for the quick reply. I think your answer will force idealforms to validate the field, which isn't really what i want.

I'm looking for a way to TELL idealforms that a field is valid/invalid/unverified (this goes back to my previous question about a 3 state custom filter which does't seem possible). I suppose that means abandoning your verification and doing it all myself. I know that's kind of what idealforms is all about but at least i'll still have great looking forms.

Is my best option to disable all verification and set the DIVs class to valid/invaid/blank myself?

elclanrs commented 11 years ago

I don't understand what the purpose of this is. Maybe an example would help.

estilian commented 11 years ago

I need something similar. I'm using some ajax events (outside the ajax method in idealforms) and I want to return an error with message to a certain input? How can I do that? I'm calling the ajax with a flag, so a flag calling error would be great :)

aim12340 commented 11 years ago

Hi elclanrs, sorry to reply so late. i've ha to move on o a different solution, but i do think this would be a good addition to your forms.

I had a calculator form where you type in a value in 2 fields and another field gives the result. I wanted the UI feedback to have 3 states like this:

One way to do that was to have the validation routine return a result that can have 3 values (valid/invalid/unverified), but idealforms forces valid or invalid only. This would be best as idealforms already has these 3 states, but i can only use 2 of them.

Another way is to allow me to set the valadtion status from outside the validation routines, so i run my own function and tell the field whether it is valid or not (or unverified).

hope that makes sense.