| Author |
Javascript Problem in document.forms
|
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 205
|
|
Hi Ranchers,
Recently, I came across a condition in our application where we had multiple forms in a single jsp and we had to validate special characters for title field. we had 2 Title fields name linkTitle and fileTitle. Something which i got from google and customized for our behaviour is as follows :
Now, What i am trying to do in the above is calling the special character function with a formName and fieldName which should get replaced at runtime and validate the said field, viz linkTitle if formName is addLinkForm and fileTitle if form name is uploadFileForm.
Some this piece of code isnt working and it always gives an error saying "document.formName.FieldName is undefined" , Can someone please help me on this since i need to get this working.
Thanks in advance,
Yogendra N Joshi.
|
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
|
Without indentation, your code is very hard to read. Do you really not indent your code?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
Using document.formName.fieldName is a very old-fashined way to address the elements.
Step into the modern era, assign each field an id, and use document.getElementById() to locate it.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
Use a regular expression, there is no need to look at every single character in a loop.
Eric
|
 |
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 205
|
|
Hi ,
Thanks for the reply. I have this regex and its special characters for matching up but it always returns false even if it contains special character or it doesnt. Please check this.
Please help me on this guys,
thanks.
Yogendra
|
 |
Yogendra Joshi
Ranch Hand
Joined: Apr 04, 2006
Posts: 205
|
|
Hi Guys,
I am done with the validation. I used Regex as suggested and my validation works wonders.
Thanks everyone for help,
Yogendra.
|
 |
 |
|
|
subject: Javascript Problem in document.forms
|
|
|