Friday, 11 April 2014

How to enter data in only 1 textbox if we have 2 textbox's in our page using jquery (generics)(2nd box will set to readdonly)

 <script type="text/javascript">      
        function OnChangeEventforpercentage() {
            compareValues(document.getElementById('x'), document.getElementById('y'));
        }

        function OnChangeEventfordiscount() {
            compareValues(document.getElementById('y'), document.getElementById('x'));
        }


        function compareValues(x, y) {          
            var value = x.value;         
           if (value == "") {
                $(y).prop('readonly', false);
            }
            else if (value != "" ) {
                $(y).prop('readonly', true);
            }
          
           
        }

    </script>

No comments:

Post a Comment