OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to prevent page reload after alert box on key down event?

  • Thread starter Thread starter sandy
  • Start date Start date
S

sandy

Guest
I want to prevent page reload after clicking ok on alert box. click search button is ok. But now I meet problem in enter key down event. Someone help me please.

This is my html

Code:
<div id="email">
 <input type="text" id="txtSearchEmail" name="email" onkeydown="Javascript: if (event.keyCode==13) {JS_Search(); event.preventDefault();}" style="width: 161px; height: 16px; padding: 2px; border: 1px solid #a8a8a8; font-size: 13px; color: #434343" />
</div>
<div id="search">
<a class="gai-button" style="width: 96px; height: 25px;" onclick="JS_Search();"><img  src="images/findamessage_search.jpg" alt="" /></a>
</div>

This is my javascript

Code:
if() {
//some coding
}
else {
alert ("Not found!");
return false;
}

<p>I want to prevent page reload after clicking ok on alert box. click search button is ok. But now I meet problem in enter key down event. Someone help me please.</p>

<p>This is my html</p>

<pre><code><div id="email">
<input type="text" id="txtSearchEmail" name="email" onkeydown="Javascript: if (event.keyCode==13) {JS_Search(); event.preventDefault();}" style="width: 161px; height: 16px; padding: 2px; border: 1px solid #a8a8a8; font-size: 13px; color: #434343" />
</div>
<div id="search">
<a class="gai-button" style="width: 96px; height: 25px;" onclick="JS_Search();"><img src="images/findamessage_search.jpg" alt="" /></a>
</div>
</code></pre>

<p>This is my javascript </p>

<pre><code>if() {
//some coding
}
else {
alert ("Not found!");
return false;
}
</code></pre>
 

Latest posts

M
Replies
0
Views
1
Marcos R. Guevara
M
Top