Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem to submit form using javascript in struts

 
johny sil
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsp page



Here is my Admin.js



when the aboue jsp is submitted it goes to the saveStatusSetup() in Admin.js, In this saveStatusSetup function is not accepted morethan two spaces in statusName property,It works fine.

But if i give morethan two spaces control will come to this function and then goes focus to the statusName property then immediatly form is submitted ,

How to stop this submission when i give morethan two spaces in statusName property

Help me,

Thanks in advance
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I think this is not really a struts question. Second, your form is not being submitted. On the button click your calling the javascript function which returns false string which is ultimately being written as the output.

You must write as below


You may want to change the cursor style on mouseover to the image.
[ August 11, 2006: Message edited by: Purushothaman Thambu ]
 
Souvvik Basu
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm re-opening this discussion, as I got stuck in something very similar. I see the code snippet here shows an attribute 'name' for the <html:form/> tag. But I checked the tag details, and there doesn't seem to be an attribute called name.
Struts Tags - form
My actual problem is this. I have a jsp page that I am submitting using an <html:button/>. On clicking the button, a javascript function gets called, which checks for empty fields. If there are any empty fields, it gives an alert. This part works fine. But when there are no empty fields, I have written a

This function is not working. The form doesn't get submitted.
Can anyone please point out my mistake here?

doesn't seem to be working, because using a name attribute in the form element gives me an error.
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using jQuery then you can probably do as following code
 
Souvvik Basu
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this. It can be achieved by document.forms[0].submit()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic