Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attributes in a field 1

Status
Not open for further replies.

rc9909

Programmer
Nov 16, 2000
3
US
I can add a self-made attribute to a input field of a form and write javascript to use this attribute for field validation. This works in ie; but it does not work in Netscape.

Is there any way for Netscape to accept added attribute of an input field, when the field is passed for validation all at once (onSubmit(this.form)? (I use elements to validate each field, but I would like to differentiate the fields, not according to type, but certain attributes that I have added inside the HTML input tag.)


In Flanagan's book "Javascript: The Definite Guide", Page 314, there is a section like this:

------------------------------------------------------
<FORM onSubmit=&quot;
this.firstname.optional = true;
this.phonenumber.optional = true;
this.zip.min = 0;
this.zip.max = 99999;
return verify(this);
&quot;>
------------------------------------------------------------

If the above would work, I would have solved my problem; But it does not work!!!

PLS HELP.

Raymond
 
Try using the inherited prototype property.You can then defining new properties for the whole class.

So use:
Object.prototype.property = &quot;some value&quot;

Where the object is your form element. I have not tested this, but it could work!
Make sure to set it before you try and use it.
-Ben. &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
The reason it works in IE is because of expando properties. These are properties you cana arbitrarilly add to an object or element at will during run-time. Netscape does not support these. prototype doesn't (to my knowledge) operate on elements based on HTMLobject (input type elements, divs, etc). You'll have to try something else, like having an array for the properties work next to the array of form elements. jared@aauser.com
 
I have posted reply but it obviously didn't show up.
Thanks, both of you for answering. Actually I am trying to create a centralized page where I can put all my javascript validation in, and then include this page as a jsp:include in all jsp pages we are working on. I tried adding a attribute to input field using simple html and it works for ie, but not netscape.

I tried prototyping; I skimmed thru the article on:
and tried it but it still didn't work. Using arrays would require prior knowledge of how many properties(attributes) I am passing in with the elements, to validate, which would not make the function 'universal'.

Maybe it is not possible to have a javascript validation page to be included in all jsp pages, that can be cross-platform compliant!!!

I don't know.

Raymond
 
maybe you can create the arrays in the page you are trying to use the validation in... jared@aauser.com
 
I think I would just put some standard javascript validations in a jsp file, and have it included in the pages. Let the people working on the pages worry about how they are going to call these functions then.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top