In SharePoint 2010, if you need to do some sort of Client side validation using Jquery or JavaScript, then PresaveAction is the one function you are looking for.
In this blog, I will discuss the steps to do a piece of client side validation of a SharePoint List Form. For example NewForm.aspx in any SharePoint List.
PreSaveAction overrides the save buttion in sharepoint form and thereby enabling inserting javascript into it.
In my customer Project, I needed to ensure that , if the Customer Account No is 16 digits and if not I need to provide the alert message saying that you need to enter minimum of 16 digit Account No.
Here is the code snippet below which I had used for implementing the logic.
  1. function PreSaveItem()
  2. {
  3. if ("function"==typeof(PreSaveAction))
  4. {
  5. return PreSaveAction();
  6. }
  7. return true;
  8. }
  9. function PreSaveAction() {
  10. return ifValidAccountNo();
  11. }
  12. function ValidAccountNo()
  13. {
  14. if(document.getElementById('customerNo').value.length !=16)
  15. alert(" Please enter Customer No with 16 digits")
  16. return false;
  17. }
If you feel that this is helpful, Please comment on the section below. And let me know if you have any suggestions to improve the same.
Happy SharePointing :-)