Saliceran
Saliceran

Reputation: 350

Using jQuery validation plugin with a form written in struts

I want to implement the jQuery validation plugin for use in a web application written in java and struts. I just want to use it to validate form inputs to see if they conform to certain rules before it's submitted to a database. The project I'm trying to implement this in was written by someone else, I don't have access to them, and I can't rewrite it.

Here is one of the form inputs that I want to validate:

<html:text property="groomFirstName" maxlength="30" tabindex="1" styleId="groomFirstName"  size="15" onchange="properCase(this.id); needToConfirm=true;"   />

I've written some custom methods for the plugin. I have tested them on a simple HTML form, but I don't how to make them work with the struts code like the line of code above.

Upvotes: 0

Views: 1283

Answers (1)

JB Nizet
JB Nizet

Reputation: 691755

The fact that Struts is used to generate the form is irrelevant. JavaScript executes in the browser, and HTML is HTML.

The line of code above is not HTML. It's a Struts JSP tag that is evaluated at server-side and generates HTML code that is sent to the browser. jQuery only cares about the HTML. And the above code will generate the following HTML:

<input type="text" name="groomFirstName" maxlength="30" tabindex="1" 
       id="groomFirstName" size="15" 
       onchange="properCase(this.id); needToConfirm=true;" />

Upvotes: 1

Related Questions