Display validation message if TextBox is Empty (Null) using jQuery in ASP.Net

Last Reply 2 months ago By chetan

Posted 2 months ago

Can anyone tell me how to display "Please enter meter reading" if textbox is empty in below code

            if($('#DynamicTable .clsRegisterReading').length > 0)
            {
                var rv = true;
                $('#DynamicTable .clsRegisterReading').each(function (key, val) {
                    debugger;
                    var metR = $(this).val();
                    var regex = /((\d+)(\.\d{1}))$/;
                    if (regex.test(metR)) {              
                        var itemRow = "<ul id='listError'><li>" + "The Meter Reading is Valid'" + " " + "</li></ul>";
                        FUNMessageBox(itemRow, "E", 700,200, "", "");
                        //$('#txt10IV_11').css('border-color', 'red');
                       
                    } else {               
                        var itemRow = "<ul id='listError'><li>" + "The Meter Reading is Invalid" + " " + "</li></ul>";
                        FUNMessageBox(itemRow, "E", 700,200, "", "");
                        // $('#txt10IV_11').css('border-color', 'red');  
                        rv = false;
                        return false;
                    }
                });
                if(rv == false)
                    return rv;
            }

 

You are viewing reply posted by: chetan 2 months ago.
Posted 2 months ago

Hi Sir,

i have used if(metr!=' ') COndition & gridview validation message outside the if and it worked for me.