I have a list on Sharepoint, and when some user add a New item, I need to validate fields... I would like something in jQuery... something that if the field is not validated, it shows a msg error and the field get red color... Is there some plugin for this?


1 Answer 1


I've never seen a plugin however; its not too difficult to do this on your own.

There is a JavaScript function in SharePoint called "PreSaveAction" that is fired just before the item is validated and saved. You can use this function to call your function. For example:

function PreSaveAction(){
    var itemTitle = $("input[title='GUID']").val();
    if (itemTitle.length < 1) {
            alert("The Title Field Cannot Be Blank");
            $("input[title='Total']").attr("style", "border: solid 1px #ff4c42 !important");
            return false;

Please note, you should do complete validation of the item because if the item fails server side validation your function will have run but the item will not be saved (causing the user to fix the validation error, hit save again, and running your function again). This may not be important if you're only doing validation, but it's worth noting.

  • thanks i will try... but I only declare the function? i dont need to call it?
    – Lugarini
    Jul 25, 2014 at 15:23
  • Correct, its called when the save button is pressed. Essentially, you're overriding a function that is always called when the save button is pressed. Jul 25, 2014 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.