Friday, October 24, 2008

JavaScript Validation on SharePoint List Item forms

I have got a requirement to write client side validation using JavaScript, which says that if a user checks a Checkbox on the List item entry from then I should enable a control on the list entry form otherwise the control should be disabled when the form loads. I was wondering how to write JavaScript on the list item forms and finally found couple of intresting things on SharePoint List item forms validations on google.
We can write JavaScript on the list item forms when the from is loading using the method "_spBodyOnLoadFunctionNames". I have found this interesting article on following blogs.


http://blogs.msdn.com/sharepointdesigner/archive/2007/06/13/using-javascript-to-manipulate-a-list-form-field.aspx

http://www.cleverworkarounds.com/2008/02/07/more-sharepoint-branding-customisation-using-javascript-part-1/

http://nqthinh.spaces.live.com/blog/cns!CA6B1F6382490EF7!227.entry

With the Help help of above Blogs I was able to write JavaScript on the list items forms.


Now my another problem is to perform client side validation on the "Submit" or "OK" button. I found this Blogs helpful for solving my problem.


http://edinkapic.blogspot.com/2007/10/add-javascript-date-validation-into.html

http://jamestsai.net/Blog/post/How-to-add-a-new-event-to-controls-in-ListFromWebPart-on-the-EditFromaspx-NewFromaspx-pages.aspx

http://phani-madhav.blogspot.com/2008/03/custom-script-while-submiting-list-item.html

1 comment:

  1. Hi Bharath,
    i have one requirment in edit form we are having 3 fields like
    1: Yes/no Field means -->check box
    2: date field----date
    3:people field: people finder
    so in this if we select first field to Yes other 2 fields should require values entered or else not required..so how can u help me how to keep dynamic required field validator for fields 2 and 3 if 1 field is checked to yes..
    Help me on this...

    ReplyDelete