• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javascript in netscape4.7

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//SCRIPT FOR IRSTAXID FIELD.THIS SCRIPT PRE-POPULATES THE FIELD WITH A '-' AS THE 4'TH CHARACTER IN THE FIELD.
//IT DOES NOT ALLOW NON-NUMERIC CHARACTER TO BE ENTERED IN THE FIELD.
<SCRIPT language=JavaScript><!--/*********The next section automatically adds '-' characters to IRSTaxId fieldsas the user types (so the user only needs to type the 20 numbers).*******/");
function IRSDisplay(i, delKey)
{ if(delKey!=8 && delKey!=46 && delKey!=9 && delKey!=16 && !(delKey>36 && delKey<41))
{
//if the delete, backspace, tab, shift, are not the keys that caused the keyup event.
var fieldLen = i.value.length;
var areaCode = "";
var exchange ="";
var lastFour ="";
var currVal = i.value;
var firstParens = 0;
var firstParens = parseInt(i.value.lastIndexOf("-")) + parseInt(1);
var secondParens = 4; ");
var secondParens = parseInt(i.value.lastIndexOf("-")) + parseInt(1);
if(secondParens < 1){ secondParens=4; }
if(fieldLen==1 && currVal!="-"){ areaCode = i.value; }
if(fieldLen>1 && currVal!="-" ){areaCode = i.value.substring(0,3);}
if(fieldLen>4 ){exchange = i.value.substring(secondParens,20);}
if(fieldLen<4){i.value = areaCode ; i.focus();}
else
if(fieldLen<20){i.value =areaCode +"-"+ exchange;i.focus();}
}
}
function IRSBlur(i){
if(i.value.length<5){

}
function testKey(i,e){
if(i.value.length==3)
chars="0123456789-";
else
chars= "0123456789";
e= window.event;
if(chars.indexOf(String.fromCharCode(e.keyCode))==-1)
window.event.keyCode=0;
}
function testdata(BusName){
if(BusName.BN.value=="") { alert("Please enter Business Name"); return false; }
else return true ;}
if(window.event){
document.NC3.captureEvents(Event.KEYPRESS);
document.NC3.onkeypress=testKey; }//-->
</SCRIPT>
<SCRIPT event=onkeyup for=IRS>IRSDisplay(this, window.event.keyCode);</SCRIPT>

//END OF JAVASCRIPT.
the error which i get after i try this code on Netscape4.7 is
----------------------------------------------------------
JavaScript Error: http://localhost:7001/CD520_CustomerCreationWizard, line 8:
i.select is not a function.
JavaScript Error: http://localhost:7001/CD521_CustomerCreationWizard?D2=0&Next=Next+%3E%3E, line
8:
i.select is not a function.
JavaScript Error: http://localhost:7001/CD521_CustomerCreationWizard?D2=0&Next=Next+%3E%3E, line
144:
window.event has no properties.
how do i get around this problem?
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am by far a DHTML expert so I may not have the answer for you, but since you are doing this in a <input type="text"> box, can't you just use onkeypress or onkeyup there without trying to capture the key event. I have never had to do anything like this, but capturing key events was for the whole page and not just for one area, but since the text box has that event, I would think you could just capture it then.
So something like:
<input type="text" name="tax_field" onkeypress="javascript:KeyPress();" value="">
and then just have a function that checks the value like you are doing right now and enters the - when it needs to.
As a side note, it may even be easier for you and the user if you just split it out into two text boxes. Like for a SSN, have a textbox with size 3, then a "-" then a textbox with size 2 then another "-" and then a third text box with size 4. Then after some hits submit you check for non-numeric entries. This has become the standard for that kind of stuff and most users are very familiar with that type of layout.
Just a thought.
Good luck and tell me how it goes.
By the way, this link has some info on the ONKEYPRESS event in Netscape, may help.
http://www.webreference.com/dhtml/diner/keypress/index.html
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic