{
//int count=0;
var txt1 = document.getElementById('txtEmpFName').value; // textbox 1 ID is txt1
var txt2 = document.getElementById('txtEmpmiName').value;
var txt3 = document.getElementById('txtEmpDtofInterview').value;
var txt4 = document.getElementById('txtEmpDtofJoining').value;
if (txt1 == "0")
{
count = count + 1;
alert("plz fill the employe's First name!!");
return true;
}
if (txt2 == "0") {
count = count + 1;
alert("plz fill the employe's middle name!!");
return true;
}
if(txt3 =="0")
{
count = count + 1;
alert("plz fill the employe's Date Of interview name!!");
return true;
}
if(txt4=="0")
{
count = count + 1;
alert("plz fill the employe's Date of joini name!!");
return true;
}
if (confirm('Do You Want to Add Record') == true)
return true;
else
return false;
}
i use this code also
it not calling function .........
pls help meeeeeeeeeee

Sunny SharmaPosted May 25, 2013, 2:36 AM
Later in your code I found that the problem lies only with your logic.
I've created a sample HTML page to demonstrate how to use Java Script functions. This will give you the whole idea. What you're currently doing is completely opposite to what you should.
You're returning true when you should not. Returning a true causes the page to proceed further while returning a false causes it to stop any further processing. See the demo in attached file.
Hope it helps!
Thanks.
Sunny SharmaPosted May 25, 2013, 2:21 AM
krishna angirekulaPosted May 25, 2013, 2:19 AM
Sunny SharmaPosted May 25, 2013, 1:59 AM
Firstly I see there's problem in your Java Script function. Properties and methods are not teh same in java script as in C#.
"txtSelectDate.Text.Trim().Length <= 0" This code will not run.
Your JavaScript code should be like this:
var txtBox = document.getElementById('txtSelectDate');
if(txtBox.value.length<=0) { ... }
OR
if you've included jQuery in your page then you can do it like:
if($('#txtSelectDate').value.length<=0) {...}
Please don't forget to accept this as answer if it helps!
Thanks.