Friday, April 26, 2013

Javascript PreSaveAction() in SharePoint 2010 Validation

Go to SharePoint List Defalut Edit or Newform.aspx.

Over there you have to put the HTML Form WebPart.

Inside the HTML Form Webpart you need add the following scripts tag and references.

Download js files from here  http://sputility.codeplex.com/

<script src="/Registry/JSFiles/prototype.js" type="text/javascript"></script>
<script src="/Registry/JSFiles/SPUtility.js" type="text/javascript"></script>

<script type="text/javascript">

function PreSaveAction() {
var item=SPUtility.GetSPField('Type of Report').GetValue(); // Choice filed Validation
if(item=="Informer")
{
     alert("Please select the Value");
     return false;

}
else
{
return true;
}
 }
</script>​

No comments:

Post a Comment