• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validate JSP form through JavaScript

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to validate a form which is using Struts tags and I am not able to validate anything from the client side through JavaScript. Basically, this is the form that I have:



Well... every time that I click on the "Search" button the JavaScript function is not executed if I left empty the textfield named "localidad". I am not sure if I am binding\passing correctly the variable named "localidad" in to the JavaScript function or maybe the validation is wrong... or maybe I need to add any other reference in the header....

Finally, I have to say that the form is working perfectly if I fill all the fields so the problem starts if I left any empty field... those fields are not validated!!

Any suggestions?

Thanks a lot one more time for your support and apologies for the code, it is in Spanish...
-S
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A few things: it's not a "JSP form". It's an HTML form. All of that Struts markup gets turned into plain HTML when it is sent to the browser. And that is what the JavaScript sees as well.

So looking at the server-side markup is not helpful; to you, or to us.

Do a View Source and see what the browser sees.

Also, open up the browser's JavaScript debugger and see what's going on. Are there errors? If so, what are they?
 
Samuel Castillo Romero
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:A few things: it's not a "JSP form". It's an HTML form. All of that Struts markup gets turned into plain HTML when it is sent to the browser. And that is what the JavaScript sees as well.

So looking at the server-side markup is not helpful; to you, or to us.

Do a View Source and see what the browser sees.

Also, open up the browser's JavaScript debugger and see what's going on. Are there errors? If so, what are they?



You gave me the key for making it works!! Basically, after viewing the code from the browser I could identify the real ID of the different resources of my form. Give that ID I was able to check if the field was empty or not so now it works nicely!!

Thanks a lot for your help on that
-S
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Just remember that when it comes to JavaScript, it's what's sent to the browser that matters; not the server-side markup.

 
I was born with webbed fish toes. This tiny ad is my only friend:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic