locked
SharePoint 2010 - JavaScript - Make a field required and add a red asterisk RRS feed

  • Question

  • Hi I use SharePoint 2010 (can use JQuery and SP Query).

    On checkbox select 
    {
     Make a date field required 
      and 
     add a red asterisk next to it
    }

    Code will be really appreciated.

    Thanks folks.

    Saturday, January 19, 2013 1:02 AM

Answers

  • Hi,

    Here is similar thread to make field mandatory using jquery:

    http://stackoverflow.com/questions/6573487/jquery-validation-select-required-if-checkbox-checked

    Second way, you can edit your page (if you want this on list forms) in infopath designer and add data validation rule on field to make it mandatory based on chkbox selection.

    Can you please let us know where you want this?


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Saturday, January 19, 2013 4:58 AM
  • Hi, 

    Dear Indul, request you to do not self propose your answer as correct.

    Hi ran009,

    You can create a lable and initially keep is display = none.

    On javascript, check it $('#controlid').text() == ''

    then mark the label display property to block and return false.

    $(document).ready(function(){
    
    $('#btn').click(function(){
    
    if($('#controlid').text == '')
    {
    $('#astrik').attr('style','display:block');
    }
    return false;
    });
    return true
    });


    Thanks, Ali Yasir http://www.sharepointstack.blogspot.in/

    Sunday, January 20, 2013 4:03 AM

All replies

  • Hi,

    Here is similar thread to make field mandatory using jquery:

    http://stackoverflow.com/questions/6573487/jquery-validation-select-required-if-checkbox-checked

    Second way, you can edit your page (if you want this on list forms) in infopath designer and add data validation rule on field to make it mandatory based on chkbox selection.

    Can you please let us know where you want this?


    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"

    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

    Saturday, January 19, 2013 4:58 AM
  • Hi, 

    Dear Indul, request you to do not self propose your answer as correct.

    Hi ran009,

    You can create a lable and initially keep is display = none.

    On javascript, check it $('#controlid').text() == ''

    then mark the label display property to block and return false.

    $(document).ready(function(){
    
    $('#btn').click(function(){
    
    if($('#controlid').text == '')
    {
    $('#astrik').attr('style','display:block');
    }
    return false;
    });
    return true
    });


    Thanks, Ali Yasir http://www.sharepointstack.blogspot.in/

    Sunday, January 20, 2013 4:03 AM