when i m trying to use the variable "txtFName1" as shown below. it doesn't work in the 'if'.
Is there any way to use the variable in the 'if' in .net 3.5
var txtFName1 = (document.getElementById('<%=txtFName.ClientID %>');
if (txtFName1== "") {
alert("First Name field can't be left blank");
txtFName1.focus();
return false;
}
Pls help
Thanx in Advance....
Eagerly waiting for the response.
Loading
Ankit NandekarPosted Apr 21, 2011, 5:17 AM
Anurag SrivastavaPosted Apr 21, 2011, 5:12 AM
Anurag SrivastavaPosted Apr 21, 2011, 5:12 AM
Sam HobbsPosted Apr 20, 2011, 3:35 PM
Ankit NandekarPosted Apr 20, 2011, 10:11 AM
Try this it will work
function Checkusername()
{
var txtusername = document.getElementById('< %=TextBox2.ClientID %>');
if (txtusername.value=="")
{
alert('Textbox must not be empty'); return false;
}
else
{
return true;
}
}
Raja KrishnamurthyPosted Apr 20, 2011, 9:13 AM
var txtFName1 = document.getElementById('<%=txtFName.ClientID %>').value; //you didn't get the value
if (txtFName1== "") {
alert("First Name field can't be left blank");
txtFName1.focus();
return false;
}
HTH