Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:47:23+00:00 2026-05-23T12:47:23+00:00

I am very new in Struts 2. I am having three text-fields in my

  • 0

I am very new in Struts 2. I am having three text-fields in my page, i put a validation for number only means (0-9) on that text-fields. In my validation.xml file code is like

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">

<validators>
    <field name="disSlab.minAmt">

        <field-validator type="requiredstring">
            <message>Required</message>
        </field-validator>
        <field-validator type="int">
                  <param name="min">0</param>
                  <param name="max">9</param>
                  <message>Data Not Valid</message>
        </field-validator>
     </field>

    <field name="disSlab.maxAmt">
        <field-validator type="requiredstring" short-circuit="true">
            <message>Required</message>
        </field-validator>

    </field>
    <field name="disSlab.schemeValue">
        <field-validator type="requiredstring" short-circuit="true">
            <message>Required</message>
        </field-validator>

    </field>

</validators>

I know that <field-validator type="int"> is not for Number Filed . but i need to prompt user when user type anything except 0 to 9..

Can you please help me abt what should i put in that Filed for validation so i can resolved my Problem.. Thanks in Adv.

Dhrumil Shah

This is not solution this is my further Details of my Question

See i have debug the source code for validation lib. it generates client side query code like this..

<script type="text/javascript">
  function validateForm_updateSlabDataFormId() {
      form = document.getElementById("updateSlabDataFormId");
      clearErrorMessages(form);
      clearErrorLabels(form);

      var errors = false;
      var continueValidation = true;
      // field name: disSlab.minAmt
      // validator name: requiredstring
      if (form.elements['disSlab.minAmt']) {
          field = form.elements['disSlab.minAmt'];
          var error = "requiredstring on amt";
          if (continueValidation && field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g, "").length == 0)) {
              addError(field, error);
              errors = true;

          }
      }
      // field name: disSlab.minAmt
      // validator name: required
      if (form.elements['disSlab.minAmt']) {
          field = form.elements['disSlab.minAmt'];
          var error = "required on amt";
          if (field.value == "") {
              addError(field, error);
              errors = true;

          }
      }
      // field name: disSlab.minAmt
      // validator name: conversion
      if (form.elements['disSlab.minAmt']) {
          field = form.elements['disSlab.minAmt'];
          var error = "Conversion needed";
      }
      // field name: disSlab.minAmt
      // validator name: int
      if (form.elements['disSlab.minAmt']) {
          field = form.elements['disSlab.minAmt'];
          var error = "Data Not Valid";
          if (continueValidation && field.value != null) {
              if (parseInt(field.value) <
                  0 ||
                  parseInt(field.value) >
                  9) {
                  addError(field, error);
                  errors = true;

              }
          }
      }
</script>

See This code is auto generated. This code is gerenerated when I submit the page. but its not generated before the page submit.. this issue is for only <field-validator type="conversion">
Not for type=required.

Can you please help me to resolve this issue..

Finally my need is
I do not want to reload a page for Number validation or any other regex validation. this is working for required validation only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:47:23+00:00Added an answer on May 23, 2026 at 12:47 pm

    This is not solution this is my further Details of my Question

    See i have debug the source code for validation lib. it generates client side query code like this..

    <script type="text/javascript">
      function validateForm_updateSlabDataFormId() {
          form = document.getElementById("updateSlabDataFormId");
          clearErrorMessages(form);
          clearErrorLabels(form);
    
          var errors = false;
          var continueValidation = true;
          // field name: disSlab.minAmt
          // validator name: requiredstring
          if (form.elements['disSlab.minAmt']) {
              field = form.elements['disSlab.minAmt'];
              var error = "requiredstring on amt";
              if (continueValidation && field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g, "").length == 0)) {
                  addError(field, error);
                  errors = true;
    
              }
          }
          // field name: disSlab.minAmt
          // validator name: required
          if (form.elements['disSlab.minAmt']) {
              field = form.elements['disSlab.minAmt'];
              var error = "required on amt";
              if (field.value == "") {
                  addError(field, error);
                  errors = true;
    
              }
          }
          // field name: disSlab.minAmt
          // validator name: conversion
          if (form.elements['disSlab.minAmt']) {
              field = form.elements['disSlab.minAmt'];
              var error = "Conversion needed";
          }
          // field name: disSlab.minAmt
          // validator name: int
          if (form.elements['disSlab.minAmt']) {
              field = form.elements['disSlab.minAmt'];
              var error = "Data Not Valid";
              if (continueValidation && field.value != null) {
                  if (parseInt(field.value) <
                      0 ||
                      parseInt(field.value) >
                      9) {
                      addError(field, error);
                      errors = true;
    
                  }
              }
          }
    </script>
    

    See This code is auto generated. This code is gerenerated when i submit the page. but its not generated before the page submit.. this issue is for only

    Not for type=required.

    Finally my need is
    I do not want to reload a page for Number validation or any other regex validation. this is working for required validation only.

    -------------------------------------------------------------------------------------------
    

    Finally i got my answer

    Let me explain who can i achieved the Solution

    My need is to put a validation for a textfield to validate Number only inputs.

    I think Struts2 provide us this basic validation but i cant find it.

    So i put a regex validation on my field like

    <field-validator type="regex" short-circuit="true">
        <param name="expression"><![CDATA[^[0-9]+$]]></param>
             <message>Not Valid Number</message>
     </field-validator>
    

    This works fine with Ajax-JQuery Validation.
    i Forgot to put CDATA in my regex. but now this works fine.

    Thanks for your support.

    Dhrumil Shah

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very new to XSL (and XML for that matter), but I need to step
I'm very new to PDO - only being told to head in that direction
Very new to HTML/CSS. How should I go about making a navbar that is
i am very new to struts and jsp and i have to make a
Im very new to java (mainly duel with embedded only) Im writing a simple
Very new to FluentNHibernate, but I'm also excited about the area. I've recently started
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Very new to using Raphael.js I'm looking at the tutorials and I am able
Very new mobile developer here... I am trying to retrieve a list of tweets
I very new to Python, and fairly new to regex. (I have no Perl

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.