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.
This message was edited 2 times. Last update was at by Yogendra 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
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.
This message was edited 1 time. Last update was at by Bear Bibeault
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 14857
posted
0
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
posted
0
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
posted
0
Hi Guys,
I am done with the validation. I used Regex as suggested and my validation works wonders.