How to keep Select as default value using JQuery in SharePoint

Advertisement
I am having a list name “Required” with two columns “Title” and “Country”, Country is required field I want to keep default value as “Select” in the Drop down and also it has to throw message as required field when the user is trying to save the item  if the default value is “Select”.

Refer the Two JS file from the internet.
jquery-1.11.0.min.js and jquery.SPServices-2014.01.min.js

<script language="javascript" type="text/javascript">
$(document).ready(function()
{
$('select[title^="Country"]').prepend('<option selected ="selected"
value="">Select</option>');
$('select[title^="Country"]').eq(0).selectedIndex = 0;
$('select[title^="Country"]').val('');
});
</script>


Copy the code in Text file and load it in Site Assets.
Refer the script path in the NewForm.aspx page by edit the page and place the content editor refer the script path in the Content Editor.
Finally it will work as shown below.
  




SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM
Advertisements
SHARE

Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment