JAVASCRIPT validation

Results 1 to 2 of 2

Thread: JAVASCRIPT validation

  1. #1
    Matthew Cahill Guest

    Default JAVASCRIPT validation

    Hi there,<BR><BR>I have a web enabled timesheet application that uses SQL and ASP. The timesheet is made up of 12 rows and 7 columns. this makes 84 input boxes.<BR><BR>Now I want to validate these input boxes to make sure the user enters an integer. Rather than have a validation script for each input box - has anyone done a similar funtion that will loop through these input boxes?<BR><BR>The hard part is that the input boxes are named the following:<BR><BR>"r1hoursc1" seven rows across to "r1hoursc7"<BR>and all the way down to<BR>"r12hoursc1" seven rows across to "r12hoursc7"<BR><BR>"r1hoursc1" obviously stands for row1 hours colomn1<BR><BR>Is there a way where a variable can be tagged onto the beggining and end of the word "hours" to make up the name of the input box, test to see if it contains an integer and then if so loop through to the next row/column etc?<BR><BR>Any response would be greatly appreciated!<BR><BR>Matt

  2. #2
    Join Date
    Dec 1969

    Default RE: JAVASCRIPT validation

    JavaScript allows the "eval" function.<BR><BR>SO:<BR><BR>function checkRowColumn( row, col )<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;boxname = "r" + row + "hoursc" + col<BR>&nbsp;&nbsp;&nbsp;&nbsp;inputBox = eval("document.formName." + boxname );<BR>&nbsp;&nbsp;&nbsp;&nbsp;val = inputBox.value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;... do validation on "val" ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;... you can even change it in form via inputBox.value = whatever ...<BR>}<BR><BR>For help on this and other JS issues, check out and the JavaScript FAQ (and other resources there).<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts