Hey Matt,
You are trying to reference the custom attribute in a way which it cannot
understand - for Mozilla you need to use element.getAttribute('type') where
'type' is your custom attribute, so in your example it would be :
element.getAttribute('Validate')
HTH
N
________________________________________
From: Matt Horn [mailto:[EMAIL PROTECTED]
Sent: 20 July 2004 13:41
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] OT : Custom form attribs + Netscape
�
Hi
I have written a sexy little javascript form validator
it relies on custom attribs within the form fields however
<input type="text" name="textbox" Validate="txt">
�
and based on the value of document.forms['theform'][x].Validate
�
a validation routine is run
�
�however Mozilla doesnt seem to be able to read the value of the custom
attrib
�
anyone know why?
�
here is my code
�
---------------------------
<script language="JavaScript">
�
�
�function loopval(formname) {
��// set up form variables
��var re = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
��theForm = document.forms[''+formname+''];
��looplen = theForm.length;
��var�errorInd =0;
��var�errorMsg ='The following errors were found\n';�
�
���alert(looplen);
����//loop over length of form
���for(i=0 ; i<looplen ; i++) {
����alert(i);
����//setup looping vars
����switchObj = theForm[i].validate;
���� formVal = theForm[i].value;
���� fieldName = theForm[i].name;
�����// NETSCAPE CHECK alert(theForm[i].validate.value);
����//switch statement
����switch(switchObj) {
�����case 'txt' : if (!isNaN(formVal)) {
��������errorInd=1;
��������errorMsg =errorMsg + 'The field '+fieldName+' must contain
alphanumerics\n';
��
��������};
�����break;
�����case 'nmb' : if (isNaN(formVal)) {
��������errorInd=1;
��������errorMsg = errorMsg +'The field '+fieldName+' must contain only
numbers\n';
��
��������};
�����break;
�����case 'email' : if(!formVal.match(re)) {
���������errorInd=1;
���������errorMsg = errorMsg +'The field '+fieldName+' must contain a
syntactically valid Email address\n';
���������};
��������break;
����
����}�
���}
���if (errorInd ==1) {
����alert(errorMsg);��
����}
���else {theForm.submit(); }�
��}�
�
</script>
�
<form name="test" method="post" action="test.cfm">
�
�<input type="text" name="txtbox"� validate="txt">
�<input type="text" name="txtbox"�� validate="nmb">
�<input type="text" name="txtbox"�� validate="email">
�<input type="text" name="txtbox"�� validate="that">
�<input type="text" name="txtbox"�� validate="other">
�<input type="button" onclick="loopval('test');">
�
</form>
�
�
|\--------------------/|
Matt Horn
Web Applications Developer
Ph:+2782 424 3751
W: http://www.matt-horn.org
E:[EMAIL PROTECTED]
|\--------------------/|
This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant,
Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business,
Registered in England, Number 678540. It contains information which is
confidential and may also be privileged. It is for the exclusive use of the
intended recipient(s). If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful. If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910. The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions.
Visit our website at http://www.reedexpo.com
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]