views:

34

answers:

3

I want to throw an error message if user doesn't input any value for a particular field. I am using blur event. I don't want to use ALERT function for throwing error messages. What are the other options we have available in jquery for error handling?

A: 

It sounds like you're looking for form validation, for which there's a jQuery plugin.

Jamie Ide
That's a wrong link. I am already using validation plugin , but for custom field, I have added a custom method which I am extending for checking blank values.
yogsma
I fixed the link. You can do custom validation with the plugin: http://docs.jquery.com/Plugins/Validation/Validator/addMethod
Jamie Ide
+1  A: 

I use jquery validation plugin

use class requried

mcgrailm
+1  A: 

Since you're validating a form, I'd strongly suggest you use the jQuery Validate plugin. It is widely used by major sites and is very user-friendly - for example, doesn't show any form errors until they've tried to submit the form, in case they were coming back to fill something in, but after that gives immediate feedback when the field is correct.

What that plugin does to display errors is append them to the page itself. For your own error handling, you can leave placeholder elements on the page, then place messages in them and show() or hide() them as necessary.

Nathan Long