4 Responses

  1. Matthew Cummings
    Matthew Cummings at |

    Hello and thank you for this information. I’m new to jQuery and webform development using SharePoint. I am interested in client side form validation and so far, this is the most information I’ve found on the subject. I do have questions though…
    Background: I work in a hospital for Supply Chain. We get requests to add items to inventory. We use SharePoint as a replacement to the old paper request forms. I created a master list “Item_Master” that contains all of the data-points for all of the variations of request types. This master list is updated by many different departments (depending on the request type), such as Inventory, Purchasing, etc. As such, the only list validation centers on the fields necessary to create the initial records.

    I want to use Client Side validation to ensure subsequent edits to the list are both of valid data types and to ensure certain fields are filled out by the end users.

    Your example used the “NewForm.aspx” and the Content Editor web part. Unfortunately, I use custom forms so you lose me right around step #5 of your tutorial.

    I instead, added the code example at the end of my test page, just before the tag and I enclosed the code with the appropriate tags and replaced the [title=''] with the names of my fields.

    I get partial functionality up to the “Save” button part. Can you explain how to customize the “$(“input[value='Save']“).each(function ()” part of your code to prohibit saving the record edit when fields remain un-validated?

    example: I used the email validate function and the required function. Both generate the red lettering next to the fields until they are properly populated but I can still click “OK” and update the record even when validation fails.

    Thank you for your time,
    Matthew Cummings

  2. wm5
    wm5 at |

    In SharePoint 2013 the name attribute is not added to the field element. This attribute is needed for the jquery validation plugin to work.

    To solve you must add the name attribute for each field you want to validate.

    $(“input[title='E-mail Address']“).attr(“name”, $(“input[title='E-mail Address']“).attr(“id”))

  3. Mike
    Mike at |

    Hello Guilong,

    Thanks for the information posted. I want to know whether it will work in Sharepoint 2010. On my task list, I want Due Date and Task Assignee to be mandatory, when user edits an item.
    So I want to add the script in Edit Item form ( I have created a new edit form and saved it as default one), but it is not working yet.

    I am hopeful, that with your comments, it might work.

    Thanks & Best Regards,

Leave a Reply