• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validating Dynamic Form

 
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Data Entry Form. With many Data Entry fields. I'm using Javascript in two ways. (1) to Validate Data and (2) to manipulate the Form,

I have two fields that relate to each other. I have a drop down box that contains values of 0 thru 24, If user selects anything greater then zero, I use the following code to open up a number of text boxes ( used to enter dates ) the user requested :

var txtbox = document.createElement("input");
txtbox.type = "text";
txtbox.name = "sqDate" + (cellCnt - 1);
txtbox.id = "sqDate" + (cellCnt - 1);
txtbox.value = "mm/dd/ccyy";
cell1.appendChild(txtbox);

In my form (jsp) I have created an empty table <table id="sQmTable" cellspacing="0" border="0" > </table> So the text boxes are created inside this table. This works just the way I want it, but how do I know when the user enters data so I can validate it ? Where would I check for this event ? Would I use "onchange" ? Etc. ?

Thanks for any help
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use code tags when posting code


 
Joe Brigs
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to add a variable like below, where my name = sqdate(variable), I know this syntax is incorrect. If this is possible what is the syntax ? Thanks again ( hopefully I used "use code tags" correctly, I tried )

document.addForm1.sqDate(numOfSqmToLoop).value
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Brigs wrote:Is it possible to add a variable like below, where my name = sqdate(variable), I know this syntax is incorrect. If this is possible what is the syntax ? Thanks again ( hopefully I used "use code tags" correctly, I tried )

document.addForm1.sqDate(numOfSqmToLoop).value



Why would you need that??

If you need to pass back the value you can get it with this.value.

Eric
 
Joe Brigs
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric, my apologies, I don't understand how your 1st response would work. I understand how (this) works , but let me start over. I call the function to create the textboxes when (onchange) the user tells me how many text boxes he wants. I then create the textboxes. I don't want to validate what the user enters in the textboxes until he hits the submit button , so I can validate them all at once. Because I have to check for valid dates but also check for duplicates etc.
I know the name of my textboxes sqDate# ( and I know what the # should be , 1 thru something) . So I wanted to loop thru each one doing the validation and replacing the # with a valid value. Hopefully this explains my problem better. Thanks Joe
reply
    Bookmark Topic Watch Topic
  • New Topic