How to check Textbox contains any values or not?

 Posted by vishalneeraj-24503 on 1/12/2014 | Category: JavaScript Interview questions | Views: 906 | Points: 40
Answer:

We can check with 2 ways:-

var txt_emp_salary = document.getElementById("<%=txt_employee_salary.ClientID%>");


if(txt_emp_salary !=null)
{
//1st way
if(txt_emp_salary.value!= '')
{
alert('Textbox has a value');
}

//2nd way
if(txt_emp_salary.value.length>0)
{
alert('Textbox has a value');
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response