Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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