Skip to content
Loading
Why i am getting error Cannot set property 'value' of null  
  •   
  • "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">  
  • "text/javascript" src="/Scripts/CustomScript.js">  
  •   
  •   
  • custom script  
  • function login_click() {  
  • //if (document.getElementById("#txtUserName") == null) {  
  • // alert('ss');  
  • //}  
  • //document.getElementById("#txtUserName").removeAttribute('style');  
  • //document.getElementById("#txtPassword").removeAttribute('style');  
  • if ($('#txtUserName').val() == "") {  
  • document.getElementById("txtUserName").style.borderColor = "red";  
  • return;  
  • }  
  • if ($('#txtPassword').val() == "") {  
  • document.getElementById("txtPassword").style.borderColor = "red";  
  • return;  
  • }  
  • var UserName = $('#txtUserName').val();  
  • var Password = $('#txtPassword').val();  
  • $.ajax({  
  • url: "/Login/AuthenticateLogin",  
  • type: "POST",  
  • data: {  
  • encuname: UserName,  
  • encpwd: Password  
  • },  
  • cache: false,  
  • async: true,  
  • dataType: "json",  
  • success: function (data) {  
  • if (data.Success) {  
  • window.location.href = "/Home/Index";  
  • }  
  • else {  
  • document.getElementById("#txtPassword").value = "";  
  • $('.alert').fadeIn(500);  
  • setTimeout("$('.alert').fadeOut(1500);", 3000);  
  • }  
  • },  
  • error: function () {  
  • document.getElementById("#txtPassword").value = "";  
  • $('.alert').fadeIn(500);  
  • setTimeout("$('.alert').fadeOut(1500);", 3000);  
  • }  
  • });  
  • }  
  • function removeBlankValidation(txtBox) {  
  • if (txtBox.value != "") {  
  • txtBox.removeAttribute('style');  
  • }  
  • }  
  • 1 Reply

    Know the answer? Post it — somebody with the same question will find it here.