adsense

Tuesday, June 27, 2017

Enable/Disable button when checkbox clicked

This can be easily achieved using jQuery as displayed below.

//bind this event in pageLoad or Dom Ready

$("#chkAgree").click(function(e) {
  $("#btnSave").attr("disabled", !this.checked);
});

Regards,
Samitha

Friday, June 2, 2017

asp.net textbox Enter key press focus to next control

The default behavior when  pressing Enter key on textbox is to fire the form submit event.
 This default behavior can be overridden and force the input to be advanced to the next control as shown below.

<script type="text/javascript">
 
 function pageLoad(){
 //you can use the control id or class
    $("#<%=txtName.ClientID%>").keypress(function (event) {
                var Text = $(this).val();
                if (event.which == 13) {
                    event.preventDefault();
                    $("#<%=txtPwd.ClientID%>").focus();
                }
            });
 
     $("#<%=txtPwd.ClientID%>").keypress(function (event) {
                var Text = $(this).val();
                if (event.which == 13) {
                    event.preventDefault();
                    $("#<%=butnLogin.ClientID%>").focus();
                }
            });
 } 
 
</script>