1

I have a dropdown list in sharepoint form, it currently has a dropdownlist called Category and it is mandatory field. The field is lookup field from another team. A first item in the category is a select category. so when user does not select on an item from drop downlist i want to trigger a current out of the box error message "You can't leave this blank". However since the first item by default is select then it will not trigger the validation.

The following code i made it will trigger but it trigger the popup message. I would like to find out how to trigger like an error message similiar to mandatory textfied where you did not input the value

<script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<script type="text/javascript">

    $(document).ready(function() {

         $("input[value='Save']").click(function(){

                        var strCategory = $("select[title='Category'] option:selected").text(); 
            if(strCategory!="1"){
                    alert("Please select category")
                return false;
            }   

        });

    });
</script>

1 Answer 1

1

Regarding this issue while creating dropdown(choice) Column. In column setting select default value by choice and keep that field empty by deleting content in it .so after that while creating item it will show error message as "You can't leave this blank".

1
  • thanks. I forgot to clarify. The field is a lookup field from another table.
    – Supermode
    Commented Apr 15, 2019 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.