0
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

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by jamshed ahmed
0

I think it should be:

OnClientClick="return ShowMsg()"

You may have to return true in ShowMsg as default.

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.