tags:

views:

488

answers:

3

Hi,

i want to validate a form, and i want its function like twitter sign up form. Now if i use change event it trigger only after text filed value change and it losses focus, and if i use keyup event it will start validating as soon as he start filling the form.

Cann any one suggest best way of doing this and am using jquery

+1  A: 

You might want to look at using a jQuery form validation plugin. I've had success with this one in the past.

dylanfm
thanx for your advice. I don't want to use plugin for this.
vinay
+1  A: 

use $('input').blur(callback);

This will make jquery validate the user input when the user leaves the field.

From experience, that's the only moment it is actually welcomed by the user. keyup is really annoying. For instance, it leads to interface telling the user he is wrong, when he only has just started typing. Pretty rude.

change() is good if your field has its value changed because of the user changing a value of another input, like in a multiple dropdown questionnaire.

pixeline
Am using .blur even only, but i want send ajax call while typing with some delay, if i use keyup it will send request on each word.
vinay
then use keyup() and in the callback, check first that there are more than, say, 4 characters typed in. if not, don't do the ajax call.
pixeline
PS: it would be nice that you put ALL details in your question in the first place.
pixeline
A: 

What server-side language are you using?

If you're using ASP.NET then you can always drop on a field-validation control. Otherwise, .blur() as suggested by pixeline would be suitable.

James Wiseman