...

View Full Version : validate text field



nikko50
05-05-2008, 01:30 PM
Hi all. I have the below function to validate a text field. On one page this charge account field is duplicated for several rows and is named "charge[]". How can I alter the below function to validate each row if each field is named the same.?

//VALIDATE CHARGE
if(theForm.charge){
if(!theForm.charge.value.match( /(^\d{5}$)|(^\d{6}$)|(^\d{6}-\d{6}$)/) ){
alert("Please input a valid Charge Account!")
theForm.charge.style.backgroundColor='pink';
theForm.charge.focus();
return false
}}

Philip M
05-05-2008, 02:19 PM
Tracy -

You often ask for assistance in this forum, but as far as I can see you never offer any thanks to people who assist you. Your statistics show 224 posts but 0 thanks given. In fact you were provided with this regex only the other day.

I was just wondering if there is any particular reason why you do not trouble to thank those who assist you, but just make like Oliver Twist - "Please sir, I want some more".

Arty Effem
05-05-2008, 02:32 PM
How can I alter the below function to validate each row if each field is named the same?Test the element for the presence of a .length property. If it has one, loop through the elements. Arrange it so that it only alerts once even if multiple fields fail, ideally without using a break statement.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum