Performing validator plug-in based client side declarative form validation:-
Step1:- Perform all the ten steps of previous class on Struts app’s (StrutsDemo App1-Dv)
Step2:- Take formpage as input page of action class (register.jsp)
Step3:- Add html: java Script tag in the form page having form bean logicalname
<html: javascript form name = “rf”/>
Note: – The above step generated one dynamic javascript function having the javascript code of form validation (validator plug-in supply) that javascript function name notation is validate form bean logical name.
Validate <FormBean logicalname>(this)
- if form bean logical name is “rf” then the function name would be validateRF (-)
For example if form bean logical name is “abc” then the function name could be validateABC (-)
Call the above step generated dynamic javascript function against on submit event in <html: form> tag of form page.
On submit = “return validateRF (this)”
Register.jsp:-
<html: javascript formname = “rf”/>
< html:form-action = “register” method= “get” on submit = “return ValidateRF (this)”>
Username: < html: text property= “username”/> < html: errors property= “username”/><br>
Password: < html: password property= “password”/> < html: errors property= “password”/><br>
<html: submit value = “checkDetails”/>
</html: form>
Note: – Since validator plug-in performs both cliect side & server side form validations even though script code (javascript) even is disabled through browser settings, the server side form validation ligic takes place automatically.
To disable scriptcode in Internet Explorer:-
- Select Tools and the following
- Internet
- security tab
- logical internet
- custome label
- Scripting
- Actionscripting
- disable.