Client Side Javascript validation in SharePoint

What do you do for performing validations on SharePoint NewForm.aspx and EditForm.aspx??

Write event handlers….That is the common answer we get….But that requires custom code and runs after the form has been submitted to the server.

There is a way by which you can  add javascript validation using the PreSaveAction(). In my earlier post I have mentioned how do you add a content editor web part to newform and editform.aspx to add you javascript here

Implement PreSaveAction() function in javascript. This function is called  on client side when “OK” button is clicked, before posting the page to the server.

function PreSaveAction()

//implement your validation logicreturn true;//Sucess,page will be posted back //OR

return false; //Failure,Cancel the save

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.