locked
TextBox RRS feed

  • Question

  • User-1499457942 posted

    Hi 

      I have 3 text boxes . I am storing Location in all 3 boxes. I want all textbox have unique values. Same Location should not exist in another table before Save

    Sunday, December 2, 2018 3:44 AM

All replies

  • User-1716253493 posted

    maybe you check if tb1.text!=tb2.text and tb1.text!=tb3.Text and tb2.text!=tb3.text

    Sunday, December 2, 2018 7:12 AM
  • User61956409 posted

    Hi JagjitSingh,

    I have 3 text boxes . I am storing Location in all 3 boxes. I want all textbox have unique values. Same Location should not exist in another table before Save

    As oned_gk mentioned, you can get and compare the values of these textboxes in your code logic.

    For example, you can valid user inputs on "Save" button client side click event, like below.

    <asp:Button ID="btnsave" runat="server" Text="Save" OnClientClick="return CheckLocationInputs();" />
    <script>
        function CheckLocationInputs() {
            var txt_l1 = $("#txt_location1").val().trim();
            var txt_l2 = $("#txt_location2").val().trim();
            var txt_l3 = $("#txt_location3").val().trim();
    
            if (txt_l1 != txt_l2 && txt_l1 != txt_l3 && txt_l2 != txt_l3) {
                alert("ok");
                return true;
            }
             alert("inputs have duplicate values");
            return false;
        }
    </script>

    With Regards,

    Fei Han

    Monday, December 3, 2018 5:50 AM