• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 492
  • Last Modified:

Enter key press opens a new window

Hi

I found a strange behaviour for input boxes inside a modal window. I am opening a popup using modal window. Inside this window I have input boxes. For this boxes I have written special chars validations on keypress. But when I press ENTER key it does not validate but opens the same file inside a new window. Is it a bug??
0
gops1
Asked:
gops1
  • 3
  • 2
1 Solution
 
callrsCommented:
Say your validation function is called "Form_Validator". Then put this statement in your form tag:
onsubmit="return Form_Validator(this)"

Here's an example from someone's site:
<form action="../_vti_bin/shtml.dll/modulo.htm" method="POST" name="FrontPage_Form1" language="JavaScript" onsubmit="return FrontPage_Form1_Validator(this)">

-------
Now, in your validation function, return false to not submit the form (e.g. if user has made an error), or true to submit the form (if user input is OK).

---
Make sure your input boxes are enclosed in  these tags: <form onsubmit=...> ... </form>
0
 
gops1Author Commented:
This happens only when I call the page inside a ModalWindow. Just to check I created a sample modal window with a input box and there too it behaves the same
0
 
pradeepsudharsanCommented:
     <base target="_self">
add this code in your page
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
gops1Author Commented:
But I am not redirecting anywhere. Would like to know why this behaviour
0
 
gops1Author Commented:
Since I could not get what I expected, I am closing this query. But anyways thanks a lot for the effort you all have put to help me out.
0
 
callrsCommented:
If you post enough code to allows us to re-create the problem, then there's better change that we can fix it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now