Advertisement

11.12.2008 at 11:41PM PST, ID: 23900990 | Points: 500
[x]
Attachment Details

Filed level validation with Vaildator-Framework in form of alert messages

Asked by NisaAkeel in Java Server Pages (JSP), JavaScript Frameworks

Tags: ,

I have to implement field level  validation in jsp pages using struts1.2 Validator-Framework.
Requirement is like the Error messages should not be displayed in the screen(as normally <html:errors /> tag does),it should be thrown as alert messages.
The user has to alerted if he enters invalid data & focus should be set to same input field with blue background  unless until valid input is given to it.

I have tried with below code snippet :
jsp:

<%@taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<html:html locale="true">
<body>
<html:errors />
<html:form action="/validity" method="post"
      onsubmit="return validateValidForm(this);" focus="myName">
      <table>
            <tr>
                  <td><bean:message key="label.groupName" /></td>
                  <td><html:text property="groupName" maxlength="25" size="26"
                        onchange="return validateMask(form) && validateMinLength(form);" /></td>
            </tr>
            <tr>
                  <td><bean:message key="label.blendedPercentage" /></td>
                  <td><html:text property="blendedPercentage" maxlength="25" size="26"
                        onchange="return validateInteger(form) && validateIntRange(form);" /></td>
            </tr>
            <tr>
                  <td><html:submit property="method">
                        <bean:message key="btn.press" />
                  </html:submit></td>
            </tr>
      </table>
      <html:javascript formName="ValidForm" />
</html:form>
</body>
</html:html>

validation.xml
<formset>
            <!-- BEGIN WebServer Remote Page -->
            <form name="groupDetailsFormBean">
                  <field property="groupName" depends="required,mask,minlength">
                        <arg0 key="label.groupName"/>
                        <var>
                              <var-name>mask</var-name>
                              <var-value>^[a-zA-Z]*$</var-value>
                        </var>
                        <arg1 key="${var:minlength}" resource="false" />
                        <var>
                              <var-name>minlength</var-name>
                              <var-value>3</var-value>
                        </var>
                  </field>
                  <field property="blendedPercentage" depends="required,integer">
                        <arg0 key="label.blendedPercentage" />
                        </field>
            </form>
      </formset>

Problem is whenever the user has provided invalid input & he wishes to  close the browser.
Normally, the user has to close the "Alert message"  & then close the browser.
But I am promoted with second alert  message "Invalid Input" after closing which the user is allowed to close the browser.

Sorry i cant provide the screen-short.
 
Please provide a solution.Is my approach Wright or there exist another one solution for my Field level validationrequirement.Start Free Trial
[+][-]11.13.2008 at 12:56AM PST, ID: 22948030

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 02:28AM PST, ID: 22948421

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 07:33PM PST, ID: 22957087

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 10:20PM PST, ID: 22957582

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 10:58PM PST, ID: 22957689

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 11:40PM PST, ID: 22957815

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 12:40AM PST, ID: 22957979

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 12:45AM PST, ID: 22957996

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 01:39AM PST, ID: 22958223

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2008 at 08:02AM PST, ID: 22960726

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2008 at 10:16PM PST, ID: 22973609

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628