473,414 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

how to validate fields in mozilla Firfox its working in IE but not working in FireFox

28
hi all,

This javascript is working IE but not working in FIreFox, validating text fields.

var dealerid = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.');
var dealinit = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.');
var dealername = new keybEdit('abcdefghijklmnopqurstuvwxyz ','Alphabets input only.');
var rank = new keybEdit('01234567890','Numeric input only.');

void function setEvents() {
document.getElementById(dealerid)onkeypress = new Function('editKeyBoard(this,dealerid)');
document.all.dealinit.onkeypress = new Function('editKeyBoard(this,dealinit)');
document.all.dealername.onkeypress = new Function('editKeyBoard(this,dealername)');
document.all.rank.onkeypress = new Function('editKeyBoard(this,rank)');

}




Expand|Select|Wrap|Line Numbers
  1. function keybEdit(strValid, strMsg) {
  2.     var reWork = new RegExp('[a-z]','gi');      //    Regular expression\
  3.     //    Properties
  4.     if(reWork.test(strValid))
  5.         this.valid = strValid.toLowerCase() + strValid.toUpperCase();
  6.     else
  7.         this.valid = strValid;
  8.     if((strMsg == null) || (typeof(strMsg) == 'undefined'))
  9.         this.message = '';
  10.     else
  11.         this.message = strMsg;
  12.  
  13.      //    Methods
  14.         this.getValid = keybEditGetValid;
  15.           this.getMessage = keybEditGetMessage;
  16.  
  17.         function keybEditGetValid() {
  18.             return this.valid.toString();
  19.         }
  20.         function keybEditGetMessage() {
  21.             return this.message;
  22.         }
  23. }
  24.  
  25.  void function editKeyBoard(objForm, objKeyb) {
  26.     strWork = objKeyb.getValid();
  27.     strMsg = '';                            // Error message
  28.     blnValidChar = false;                    // Valid character flag
  29.  
  30.     // Part 1: Validate input
  31.     if(!blnValidChar)
  32.       for(i=0;i < strWork.length;i++)
  33.           if(window.event.keyCode == strWork.charCodeAt(i)) {
  34.                blnValidChar = true;
  35.                break;
  36.             }
  37.  
  38.     // Part 2: Build error message
  39.     if(!blnValidChar) {
  40.        if(objKeyb.getMessage().toString().length != 0)
  41.           //alert('Error: ' + objKeyb.getMessage());
  42.             alert(objKeyb.getMessage());
  43.           window.event.returnValue = false;        // Clear invalid character
  44.           objForm.focus();                        // Set focus
  45.           }
  46.  }
  47.  
Jun 25 '07 #1
3 2444
gits
5,390 Expert Mod 4TB
hi,

document.all is IE specific, and other browsers like opera, konqueror, safari support it too ... but FF/Mozilla doesn't. the standards-compliant way is to use regular dom-methods for that purpose:

Expand|Select|Wrap|Line Numbers
  1. // get a reference to your desired document-node
  2. var node = document.getElementById('node_id');
  3.  
  4. // to set an attribute
  5. node.setAttribute('attr_name', 'attr_value');
  6.  
  7. // to set a property
  8. node.property_name = 'property_value';
  9.  
kind regards ...
Jun 25 '07 #2
shyamg
28
hi all,


IE the function is working but FF the function is not working how to call the function in FF.

this is my script.
Expand|Select|Wrap|Line Numbers
  1.  
  2.    var dealerid = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.');
  3.             var dealinit = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.');
  4.             var dealername = new keybEdit('abcdefghijklmnopqurstuvwxyz ','Alphabets input only.');
  5.             var rank = new keybEdit('01234567890','Numeric input only.');
  6.  
  7.  
  8.  
  9.             function keybEdit(strValid, strMsg) {
  10.     var reWork = new RegExp('[a-z]','gi');      //    Regular expression\
  11.     //    Properties
  12.     if(reWork.test(strValid))
  13.         this.valid = strValid.toLowerCase() + strValid.toUpperCase();
  14.     else
  15.         this.valid = strValid;
  16.     if((strMsg == null) || (typeof(strMsg) == 'undefined'))
  17.         this.message = '';
  18.     else
  19.         this.message = strMsg;
  20.  
  21.      //    Methods
  22.         this.getValid = keybEditGetValid;
  23.           this.getMessage = keybEditGetMessage;
  24.  
  25.         function keybEditGetValid() {
  26.             return this.valid.toString();
  27.         }
  28.         function keybEditGetMessage() {
  29.             return this.message;
  30.         }
  31. }
  32.  
  33.  void function editKeyBoard(objForm, objKeyb) {
  34.     strWork = objKeyb.getValid();
  35.     strMsg = '';                            // Error message
  36.     blnValidChar = false;                    // Valid character flag
  37.  
  38.     // Part 1: Validate input
  39.     if(!blnValidChar)
  40.       for(i=0;i < strWork.length;i++)
  41.           if(window.event.keyCode == strWork.charCodeAt(i)) {
  42.                blnValidChar = true;
  43.                break;
  44.             }
  45.  
  46.     // Part 2: Build error message
  47.     if(!blnValidChar) {
  48.        if(objKeyb.getMessage().toString().length != 0)
  49.           //alert('Error: ' + objKeyb.getMessage());
  50.             alert(objKeyb.getMessage());
  51.           window.event.returnValue = false;        // Clear invalid character
  52.           objForm.focus();                        // Set focus
  53.           }
  54.  }
  55.  
  56.  
  57.  
  58.             void function setEvents() {
  59.  
  60.             document.getElementById(dealerid)= new Function('editKeyBoard(this,dealerid)');           
  61.             document.all.dealinit.onkeypress = new Function('editKeyBoard(this,dealinit)');
  62.             document.all.dealername.onkeypress = new Function('editKeyBoard(this,dealername)');
  63.             document.all.rank.onkeypress = new Function('editKeyBoard(this,rank)');
  64.  
  65.             }
  66.  
  67.  
this is also not working ,


how to validate fields.


Thanks.

ss.
Jun 26 '07 #3
acoder
16,027 Expert Mod 8TB
You're still using document.all. Change that to document.getElementById. You should probably see errors in the Javascript console.
Jun 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: DM | last post by:
I searched on this topic. Found others who mentioned it, but no solution. I can't seem to get visited links to appear in a different color in Mozilla or Firefox on the PC. It works fine in IE. My...
4
by: John Bullock | last post by:
Hello, I am at wit's end with an array sorting problem. I have a simple table-sorting function which must, at times, sort on columns that include entries with nothing but a space (@nbsp;). I...
8
by: Dean Speir | last post by:
Hi... I've been referred to this Newsgroup by the W3C Markup Validator FAQ. I've been happily using this Validator <http://validator.w3.org> for the past 18 months with great success, but...
4
by: madsgormlarsen | last post by:
When you write html or css then the validation proces is a good way of finding errors. I get some syntax error / code: 0 errors in IE, how can I figure out what the problem is. The thing is - it...
0
by: BACON | last post by:
I'm just starting the process of reorganising my modest little website and cleaning up all the HTML, and the logical place to begin was with the homepage. I made a simple little ASP.NET control...
5
by: BACON | last post by:
I'm just starting the process of reorganising my modest little website and cleaning up all the HTML, and the logical place to begin was with the homepage. I made a simple little ASP.NET control...
1
by: ajaysoniji | last post by:
Hi, I am using this code to read the option values from a select option. I am getting the reference of that select option in arg1. Its working fine with mozilla firefox but not with Internet...
7
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has...
2
by: sajithamol | last post by:
How can i migrate one application from IE to Mozilla Firefox. while working in IE , javascript was working perfectly . But when i used Mozilla firefox , javascript not working. How can i make one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.