File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Urgent::Problem with Form submission,JS,Enter key Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Urgent::Problem with Form submission,JS,Enter key" Watch "Urgent::Problem with Form submission,JS,Enter key" New topic
Author

Urgent::Problem with Form submission,JS,Enter key

archana vishwanath
Ranch Hand

Joined: Mar 09, 2004
Posts: 39
Hi friends,
Im facing problem with this code.My javascript here gets invoked with mouse press in the button,but not in Enter key.
Can any body help me to sort out this.(i.e)If I invoke the form by directly hitting the keyboard enter button with out
using mouse,my javascript is not getting invoked.

This is my javascript
---------------------
function arsubmit(){
if(document.frm1.T1.value==""){
document.frm1.T1.focus();
alert("Please enter Batch name");
return false;
}
else{
javascript ocument.frm1.submit();
}
}
Im using this to invoke my script
Note
onKlick="return arsubmit();
I have used Klick insted of click purposely because the javaranch server is not allowing me to submit the exact code
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
becasue onclick does not use the enter key!
you need to use the onsubmit handler in the form tag
<form name="blah" onsubmit=return jsFunction()">
return true to submit false to ignore with your function.
P.S. Using Urgent makes me want to skip the question so do not use it in your title!
Eric
archana vishwanath
Ranch Hand

Joined: Mar 09, 2004
Posts: 39
SORRY & Thanks ERIC
It worked.
<form name =frm1 method=get action="AAA.jsp" onsubmit="return arsubmit();">
by this way.
archana vishwanath
Ranch Hand

Joined: Mar 09, 2004
Posts: 39
ERIC I'm facing one more problem,I want to get the value of my submit button in my next page,which is not available when I use onsubmit method.Pls advice me how to overcome this.
I need these submit values.
input type="submit" name="stasubmit" value="Save & exit"
input type="submit" name="stasubmit" value="Save & add new
 
IntelliJ Java IDE
 
subject: Urgent::Problem with Form submission,JS,Enter key
 
Threads others viewed
invoke js method
After submit the link parameter get null
JSF form: using ENTER as TABULATOR key
HTML +Javascript submit query??
onblur and event at the same time !
IntelliJ Java IDE