here is java script code
function ShowMsg()
	{
	if(document.getElementById("txtVerifierName").value=="")
	{
	alert("PLEASE ENTER VERIFIER NAME..");
	return false;
	}

<asp:Button ID="btnAdd" runat="server" Text="ADD" OnClientClick="ShowMsg()" onclick="btnAdd_Click"  />

NOW THE PROBLEM IS THAT WHEN I CLICK THE BUTTON, IT SHOWS THE MESSAGE THAT PLEASE ENTER VERIFIER NAME BUT EXECUTION DOESN'T STOP THERE, AFTER SHOWING MESSAGE IT EXECUTES btnAdd_Click AND THIS BUTTON CONTAINS CODE FOR THE INSERT QUERY. SIMPLE WHAT I WANT TO DO IS, IF VERIFIER TEXTBOX IS EMPTY IT SHOULD SHOW THE MESSAGE ON CLIENT SIDE AND DON'T INSERT RECORD, OTHERWISE EXECUTE INSERT QUERY.PLZZZ HELP

I think it should be:

OnClientClick="return ShowMsg()"

You may have to return true in ShowMsg as default.

You should check the value of :
txtVerifierName.text before executing the insert statement.

sub btnAdd_Click

if (txtVerifierName.text="") then
Do not Insert
else
Insert Record;

end sub


here is java script code
function ShowMsg()
	{
	if(document.getElementById("txtVerifierName").value=="")
	{
	alert("PLEASE ENTER VERIFIER NAME..");
	return false;
	}

<asp:Button ID="btnAdd" runat="server" Text="ADD" OnClientClick="ShowMsg()" onclick="btnAdd_Click"  />

NOW THE PROBLEM IS THAT WHEN I CLICK THE BUTTON, IT SHOWS THE MESSAGE THAT PLEASE ENTER VERIFIER NAME BUT EXECUTION DOESN'T STOP THERE, AFTER SHOWING MESSAGE IT EXECUTES btnAdd_Click AND THIS BUTTON CONTAINS CODE FOR THE INSERT QUERY. SIMPLE WHAT I WANT TO DO IS, IF VERIFIER TEXTBOX IS EMPTY IT SHOULD SHOW THE MESSAGE ON CLIENT SIDE AND DON'T INSERT RECORD, OTHERWISE EXECUTE INSERT QUERY.PLZZZ HELP

i think it should be:

onclientclick="return showmsg()"

you may have to return true in showmsg as default.

ok thx for this i am very new to asp.net with javascript and hope i will get more help from you thx again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.