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

Raja KrishnamurthyRank #3,615 · 403 reputationPosted Apr 20, 2011, 5:13 AM EDT
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
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 20, 2011, 6:11 AM EDT
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;
}
}
Sam HobbsRank #107 · 20.5K reputationPosted Apr 20, 2011, 11:35 AM EDT
Anurag Srivastava38 reputationPosted Apr 21, 2011, 1:12 AM EDT
Anurag Srivastava38 reputationPosted Apr 21, 2011, 1:12 AM EDT
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 21, 2011, 1:17 AM EDT