SP List Auto complete validation to ensure user select populated item

Shri-6058 326 Reputation points
2020-11-28T17:57:35.157+00:00

Hello, I have a an issue validating user making sure he/she select the auto populated from the dropdown. I am populating post activities assigning values to other fields. If user not selected and just type values, its not happening. Is it possible to return to the same textbox if user not selected(and just typed). Something .Keyup or textbox change focus? Please advise.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
7,019 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,430 questions
{count} votes

Accepted answer
  1. Michael 17,921 Reputation points
    2020-12-02T03:36:41.607+00:00

    Hi @Shri-6058 ,

    You could create the form like this:

    @using (Html.BeginForm("Form2", "Home", FormMethod.Post))  
    {  
        <table>  
            <tr>  
                <td>Enter ID: </td>  
                <td>@Html.TextBoxFor(m => m.Id)</td>  
            </tr>  
            <tr>  
                <td>Enter Name: </td>  
                <td>@Html.TextBoxFor(m => m.EmpName)</td>  
            </tr>  
            <tr>  
                <td colspan="2"><input type="submit" value="Submit Form" /></td>  
            </tr>  
        </table>  
    }  
    

    Then add the js for validation when submit the form:

    44245-image.png

    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Michael 17,921 Reputation points
    2020-11-30T03:38:07.857+00:00

    Hi @Shri-6058 ,

    You could use the PreSaveAction() function to complete the validation. https://social.technet.microsoft.com/wiki/contents/articles/38255.sharepoint-2013-use-of-presaveaction-function-on-list-forms.aspx

    Below is my demo code:

    43517-image.png

    Test result:

    43439-presave.gif


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Shri-6058 326 Reputation points
    2020-11-30T06:44:56.58+00:00

    Thank you very much.
    I should have clarified more. Currently I have an existing mvc application auto complete(I plan to integrate directly in SP list in the next release.). I must include this validation on application form submit action I believe. I am referring mvc application backend database as SP list once form is submited.

    0 comments No comments

  3. Michael 17,921 Reputation points
    2020-11-30T08:49:12.957+00:00

    Hi @Shri-6058 ,

    How did you create the form in MVC? Could you please share more details?

    You could add the js function for validation when submit the form. For example:

    43671-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Shri-6058 326 Reputation points
    2020-12-01T06:34:48.577+00:00

    Thank you, appreciate it. I will try tomorrow and will let you know. Here is my code43874-capture.jpg

    0 comments No comments