Skip navigation
Currently Being Moderated

Validation fails when dynamically set the text field values and submit the form

May 15, 2012 4:44 PM

Hi ,


   I have mutiple text fields for inputing the date .User can enter date on one text field and select a check box to apply the smae  date to rest of all other date input fields .

    When I use ValidationTextField widget and user enters date on all fields its working fine but when users enters date in first field and selects the check box to copy the same for rest of all other date fields and submit the form, validation fails . What I have noticed is onblur  event is not fired when dynamically set the field values , I have tried dynamically calling the onBlur event but no luck .Bleow is my code base .. Thanks in advance for any help and suggestions ..





<!-- Link the Spry Validation Text Field JavaScript library -->

<script src="spry/1_6_1/widgets/textfieldvalidation/SpryValidationTextField.j s" type="text/javascript"></script>

<!-- Link the CSS style sheet that styles the widget -->

<link href="spry/1_6_1/widgets/textfieldvalidation/SpryValidationTextField. css" rel="stylesheet" type="text/css" />




function copyCancelInfo(){



                    with (document.form1){






                                         for (var i=1;i<4;i++){


                                                  eval("removalEventDate"+i).value = removalEventDate0.value;















          <form id="form1" name="form1" method="post" action="TestDateFieldServlet">

                    <!-- Create the text field widget and assign a unique id-->

                     <%for(int j=0;j<4;j++){ %>

                    <span id="CANCEL_DT_div<%=j%>">

                   <input type="text" name="removalEventDate<%=j%>" id ="removalEventDate<%=j%>"  size="10" maxlength="10" value="" />

                   <span class="textfieldInvalidFormatMsg">Please enter a valid date (mm/dd/yyyy).</span>



                    <%} %>

                    <input type="checkbox" name="copyCancelInfoCkBox" value="1" onclick="copyCancelInfo()" >



                              Copy  Date to all Fileds


          <input name="btnSubmit" type="submit"  id="Submit" value="Submit Changes"  >



<!-- Initialize the Validation Text Field widget object-->

<script type="text/javascript">

<% for(int k=0;k<4;k++){ %>

          var CANCEL_DT_div<%=k%> = new Spry.Widget.ValidationTextField("CANCEL_DT_div<%=k%>", "date", {useCharacterMasking:true, format:"mm/dd/yyyy", hint:"mm/dd/yyyy", validateOn:["blur"], isRequired:true});

<% } %>








  • Currently Being Moderated
    May 15, 2012 5:13 PM   in reply to Ramakrishna1982
    Mark as:
  • Currently Being Moderated
    May 16, 2012 4:02 PM   in reply to Ramakrishna1982

    Thank you for your feedback. Glad it worked out.



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points