Reputation: 1
I want to do this type of validation using javascript on text box in asp.net on textchange event of text box below is my code in c# validtaion:
string str = "Select ReceiptNo from BranchOutwardItems where ReceiptNo='" + txtReceiptNo.Text + "'";
DataTable dt = objGlobalClass.LoadData(str);
if (dt.Rows.Count > 0)
{
lblMsg.Text = " Receipt ID already exists.Click On ADD for Generate New Receipt ID";
}
else
{
lblMsg.Text = "Receipt ID doesnot exists";
}
Upvotes: 0
Views: 339
Reputation: 17614
For this you will have to call a Page-Method or A Web-Service, Or a Http-Handler to validate the value of the text box.
Here is a similar example
Here too is a good example
Upvotes: 1
Reputation: 190
var tbl = document.getElementById('tblID');
var lbl = document.getElementById('lblID');
if(tbl != null)
{
if(tbl.rows.length > 0)
{
lbl.innerHTML = "Success Message";
}
else
{
lbl.innerHTML = "Failed Message";
}
}
Upvotes: 0