All Type Coding

Search Here

What is a table scan?

In SQL server table When there is no index to use for searching, the result is similar to the reader who looks at every page in a book to find a word. The SQL engine needs to visit every row in a table. In database terminology we call this behavior a table scan, or just scan. A full table scan of a very large table can adversely affect the performance. Creating proper indexes will allow the database to quickly narrow in on the rows to satisfy the query, and avoid scanning every row in the table. 

Valid Mobile number validation

 function validateMobileNo(obj, evt) {

            var txtMblNo = obj.id;
            var MobileNo = $('#' + txtMblNo).val();
            var mob = /^[7-9]{1}[0-9]{9}$/;

            if (MobileNo.length < 10) {
                alert("Please enter 10 digits mobile number");
                $('#' + txtMblNo).val('');
                $('#' + txtMblNo).focus();
                return false;
            }

            if (mob.test(obj.value) == false) {
                alert("Please enter valid mobile number.");
                $('#' + txtMblNo).focus();
                $('#' + txtMblNo).val('');
                return false;
            }

        }

Email validation

 function validateEmailId(obj, evt) {

            var txtEmail = obj.id;
            var Email = $('#' + txtEmail).val();

            var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
            if (Email.match(mailformat)) {
                return true;
            }
            else {

                alert("Invalid email id entered! Please enter valid email id");
                $('#' + txtEmail).val('');
                $('#' + txtEmail).focus();
                return false;
            }
        }

How to unckeck checkboxlist based on last checkbox selection.?

<script type="text/javascript">


        $(document).ready(function () {
            $('#ContentPlaceHolder1_chk').live('click', function () {
                var values = '';
                var $ctrls = document.getElementById('ContentPlaceHolder1_chk').getElementsByTagName("input");
                $('#ContentPlaceHolder1_chk input[type=checkbox]:checked').each(function () {
                    if (values.length == 0) {
                        values = $('label[for=' + this.id + ']').html();
                    }
                    else {
                        values += "," + $('label[for=' + this.id + ']').html();
                    }

                });
                var strarray = values.split(',');
                for (var i = 0; i < strarray.length; i++) {
                    if (strarray[i] == "NA") {
                        var selValue = [1, 2, 3, 4, 5, 6, 7, 8, 9];
                        for (var j = 0; j < selValue.length; j++) {

                            $('input:checkbox[value=' + selValue[j] + ']').removeAttr('checked');
                        }
                    }
                }

            });
        });

    </script>

Numeric validation in javascript


function isNumber(e) {
            var keynum;

            keynum = e.keyCode ? e.keyCode : e.which;
            if ((keynum > 47 && keynum < 58) || keynum == 98) {

                return true;
            }
            else {
                e.preventDefault();
                alert('Please enter only numbers.');
                return false;
            }


        }