Guys i have a textbox where user enters a telephone number , i need to check in the database whether there a same telephone number in the database already , i want this to happen as soon as the textbox looses focus without posting back , is there any way to accomplish this is asp ????

Without a postback means you will need to use AJAX. You say "is there any way to accomplish this is asp". Do you mean in ASP (active server pages) or are you using .net and you meant asap?

I meant asp .net , and i meant page without refreshing when i meant postback .

In that case you defineitely want to use AJAX. Which is pretty easy in ASP.Net.
Go here http://www.asp.net/ajax and download the AJAX tool kit. Add it as a reference to your projectand you will see extra options appear in the IDE tool kit.

Basically you add an AJAX manager to the page and define which part of the page is going to use AJAX by placing a template control around the correct controls. The webiste above has tutorials that will step you through it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script>
function checkForInvalid(obj) {
	if( /[^0-9\-]|-{2,}/gi.test(obj.value) ) {
		alert("Invalid character in Invoice No.")
		obj.value = ""; // line added to clear textbox value
		obj.focus();
		// obj.select(); // line removed
		return false;
	}
	return true;
}

</script>
</head>

<body>
<form name="myForm">
<input type="text" name="invoiceNo" onkeyup="checkForInvalid(this)">
</form>
</body>
</html>

Try this will help you

i have a new problem !!!!! in "log off" function i have written the code to update cookie values to null , but when the user presses the back button the page comes up again but if the user presses any button then it doesn't work , i want to know how to make the user not see the page when they press back button

you can clear the history. is that what you want?

nope , clearing the history ll del everything !!!! but i dont want the pages related to the particular site to be removed from cache ,

and i ahve a new proble , it might sound stupid !!!!
lets say i have 3 textboxes and a button

i need to validate in such a way when the user clicks button , if one of the textboxes are empty it should throw exception , now i know how to do this both in javascript and in serverside vb script , but what i dont understand is when the user clicks button will the javascript gets executed first or serverside vb code , because if the textboxes are null server side vb code should not get executed .

Hey,
For the logging off/back button issue, are you using session state to record the user's logged in status? if yes, when they logout clear the session. Then if they go back your page should check (if you have coded it to do so) if the user is still logged in or not with the session and deny them.

Question 2, client side gets fired first but you may want to use validation controls to check for valid input. These fire before the page is posted back and if the textbox is empty, input is incorrect, etc postback stops and a message can be presented to the user.

i need to validate in such a way when the user clicks button , if one of the textboxes are empty it should throw exception , now i know how to do this both in javascript and in serverside vb script , but what i dont understand is when the user clicks button will the javascript gets executed first or serverside vb code , because if the textboxes are null server side vb code should not get executed .

javascript is executed first. now when you determine that one of the textbox is empty.

if(document.getElementById('textboxt1').value == null ||document.getElementById('textboxt2').value == null || document.getElementById('textboxt3').value == null)
{
-- some logic --
return false;
}
else{
-- some logic --
return true;
}

return false would stop the execution of the severside code.

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.