jQuery Form serialize method – does not post disabled fields

February 24, 2011


Today I had a problem where I had some disabled fields which were not getting serialized, I got two solutions for this


Validate/Revalidate a single field using jQuery validator

February 23, 2011

If you have a requirement to just do a single field validation, instead of calling the form validate method which will validate all the fields, then you have to use valid() method on the element

For example if your form has field

<input type="field" name="username" id="username"/>

to validate only username field, use code


But of course you have to link the jQuery validator plugin with your form before you call this method

Related Stack overflow post link here – http://stackoverflow.com/questions/1378472/jquery-validate-can-i-re-validate-a-group-of-fields-after-changing-one

jQuery JSONP (JSON with padding) – success method not called

February 23, 2011

Possible reasons for JSONP success method not getting called

  • In jQuery.getJSON method check if you are adding the
    callback=? param to your URL
  • Check if your server code serving JSONP request is returning proper JSONP response,

    For example sample server JSONP java code and response taken from IBM Developerworks article given below,
    Java code

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    String jsonData = getDataAsJson(req.getParameter("symbol"));
    String output = req.getParameter("callback") + "(" + jsonData + ");";


    PrintWriter out = resp.getWriter();

    JSONP Response Format

    jsonp1232617941775({"symbol" : "IBM", "price" : "91.42"});

To get a good understanding of JSONP you can read this IBM Developerworks article http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

jQuery Validator – Error: $.validator.methods[method] is undefined

February 22, 2011

Error: $.validator.methods[method] is undefined

I was getting this error when using jQuery validator, found the reason for this error was because I didn’t define the custom validator methods which I had assigned in the validation rules. More about jQuery custom validation method here – http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage

what http error code to use for validation error

February 18, 2011

I was using 500 – Internal Server Error for validation errors, but problem was the application error handler caught this and shows generic error page, which causes validation logic to fail. So instead we can use

Either use code 400 – Bad Request
or code 200 – with the error message


jQuery validation plugin , validate only visible fields

February 17, 2011

Refer this Stack overflow post for the solution


Pasting code from the post below


qTip – Excellent jQuery Tooltip plugin

February 15, 2011

If you are looking for a jQuery tooltip plugin to use for your project, http://craigsworks.com/projects/qtip/ is the right one for you.

It gives full flexibility in customizing the appearance and the behavior. Also the default settings are good, so with just couple of lines, you can put this plugin to real use in your project.

Another important aspect is its working fine in both IE8, Firefox and Chrome. The tooltip shows with rounded borders in all the browsers, and its achieving the rounded borders without images, which is cool.