• 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

javascript validations (URGENT)

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI ALL,
i wannt to do a few validations on the value of input fields.
these input fields are in jsp page and the nameis generated dynamcally inside a forloop.
for eg:
<input type ="text name="text1">
<input type ="text name="text2">
where the names "text1" and "text2" are generated dynamically..
the number of input fields also varies.
what i want to validate is the value of these input fields shud not be the same..
i.e. no two input fields shud have the same valeu.
how doi go abt doing this when i do not know the number of text fields and how doi compare eachvalue with all the other values..???
PLEASE REPLY SOON
THIS IS AN SOS
thanx to all in advance..
Chhaya
 
Chhaya Dhanani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IS THERE NO ONE WHO CAN HELP???
WHAT HAPPENED ALL OF YOU???
CAN NO ONE SAVE THE DAY FOR ME???

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chhaya Dhanani:
HI ALL,
i wannt to do a few validations on the value of input fields.
these input fields are in jsp page and the nameis generated dynamcally inside a forloop.
for eg:
<input type ="text name="text1">
<input type ="text name="text2">
where the names "text1" and "text2" are generated dynamically..
the number of input fields also varies.
what i want to validate is the value of these input fields shud not be the same..
i.e. no two input fields shud have the same valeu.
how doi go abt doing this when i do not know the number of text fields and how doi compare eachvalue with all the other values..???
PLEASE REPLY SOON
THIS IS AN SOS
thanx to all in advance..
Chhaya


Warning this is off the top of my head,I have not verified/run the code but it might be of some help:
function getArrayOfValues(){
var a = new Array()
var d = document.formanme
var x = 1;//offset for each field
while( d["text"+x] ){
a[a.length] = d["text"+x].value;
a[a.length-1].id = x;//id of the field
}
return a;
}
function checkTextValues(){
var x;
var a = getArrayOfValues();
a.sort();
for( x = 0; x < a.length-1; x++ ){
if( a[x] == a[x+1] ){
alert( "duplicate values for " + a[x] );
document.formname["text"+a[x].id].focus()
}
return "text" + a[x].id ;
}
}
[ April 11, 2002: Message edited by: Charlie Sturman ]
[ April 11, 2002: Message edited by: Charlie Sturman ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic