P
Peter
I have the following code being called by a form. As soon as I enter
a Rent such as asdff to test it, the next time I enter a number it
doesn't format and if I enter text it just becomes blank regardless of
whether its FOR SALE. The only way to get the form working again is
to either delete the temporary files or close and reopen the browser
window. Does anyone see what might be my problem.
tia,
pete
form
-----
<input type="text" name="rent" size="32" value=""
onBlur="checkDecimal(this,this.value)">
after header
---------------
<script type="text/javascript">
function checkDecimal(obj, objStr){
var objNumber;
objNumber = ' ';
if(isNaN(objStr) && objStr!=''){
if (objStr == 'FOR SALE') objNumber = 'FOR SALE';
if (objStr == 'for sale') objNumber = 'FOR SALE';
if (objStr == 'SALE') objNumber = 'FOR SALE';
if (objStr == 'sale') objNumber = 'FOR SALE';
if (objStr == 'FOR LEASE') objNumber = 'FOR LEASE';
if (objStr == 'for lease') objNumber = 'FOR LEASE';
if (objStr == 'LEASE') objNumber = 'FOR LEASE';
if (objStr == 'lease') objNumber = 'FOR LEASE';
if ((objNumber != 'FOR SALE') && (objNumber != 'FOR LEASE'))
objNumber = ' ';
}
else if(objStr==''){
objNumber = '0.00';
}
else if(objStr.indexOf('.')!=-1){
if(((objStr.length) - (objStr.indexOf('.')))>3){
objStr = objStr.substr(0,((objStr.indexOf('.'))+3));
}
if(objStr.indexOf('.')==0){
objStr = '0' + objStr;
}
var sLen = objStr.length;
var TChar = objStr.substr(sLen-3,3);
if(TChar.indexOf('.')==0){
objNumber = objStr;
}
else if(TChar.indexOf('.')==1){
objNumber = objStr + '0';
}
else if(TChar.indexOf('.')==2){
objNumber = objStr + '00';
}
}
else{
objNumber = objStr + '.00';
}
obj.value = objNumber;
}
</script>
a Rent such as asdff to test it, the next time I enter a number it
doesn't format and if I enter text it just becomes blank regardless of
whether its FOR SALE. The only way to get the form working again is
to either delete the temporary files or close and reopen the browser
window. Does anyone see what might be my problem.
tia,
pete
form
-----
<input type="text" name="rent" size="32" value=""
onBlur="checkDecimal(this,this.value)">
after header
---------------
<script type="text/javascript">
function checkDecimal(obj, objStr){
var objNumber;
objNumber = ' ';
if(isNaN(objStr) && objStr!=''){
if (objStr == 'FOR SALE') objNumber = 'FOR SALE';
if (objStr == 'for sale') objNumber = 'FOR SALE';
if (objStr == 'SALE') objNumber = 'FOR SALE';
if (objStr == 'sale') objNumber = 'FOR SALE';
if (objStr == 'FOR LEASE') objNumber = 'FOR LEASE';
if (objStr == 'for lease') objNumber = 'FOR LEASE';
if (objStr == 'LEASE') objNumber = 'FOR LEASE';
if (objStr == 'lease') objNumber = 'FOR LEASE';
if ((objNumber != 'FOR SALE') && (objNumber != 'FOR LEASE'))
objNumber = ' ';
}
else if(objStr==''){
objNumber = '0.00';
}
else if(objStr.indexOf('.')!=-1){
if(((objStr.length) - (objStr.indexOf('.')))>3){
objStr = objStr.substr(0,((objStr.indexOf('.'))+3));
}
if(objStr.indexOf('.')==0){
objStr = '0' + objStr;
}
var sLen = objStr.length;
var TChar = objStr.substr(sLen-3,3);
if(TChar.indexOf('.')==0){
objNumber = objStr;
}
else if(TChar.indexOf('.')==1){
objNumber = objStr + '0';
}
else if(TChar.indexOf('.')==2){
objNumber = objStr + '00';
}
}
else{
objNumber = objStr + '.00';
}
obj.value = objNumber;
}
</script>