Connecting Tech Pros Worldwide Forums | Help | Site Map

problem in firefox browser

Newbie
 
Join Date: Mar 2007
Posts: 1
#1: Mar 14 '07
hi,

I am facing problem with firefox2.0 browser,
Actually my problem is

i am validating a textfield using javascript.if the script return false then the cursor not focusing on failed text field...
but in IE it is happing like, if validation failed then cursor comes on wrong invalid textfield... and in this case we cant submit the form. this is actually my requirement. but in Firefox it is not happing like these...

i want IE requirement to firefox also...
please give the solution anybody...
thank you in advance.........


i also paste the code.....

Java script >>>>>>>>>>>>>>>>

Expand|Select|Wrap|Line Numbers
  1. function checkAlpha(event,tfield)
  2. {
  3.    data = tfield.value;
  4.    var field = tfield.name;
  5.    fieldName = field.replace(/_/g," ");
  6.    dataRegexp = new RegExp("^([a-zA-Z/][a-zA-Z/0-9]*$)");
  7.    var matched = dataRegexp.exec(data);
  8.    if(matched != null)
  9.     return true;
  10.    else 
  11.    {
  12.     event = (window.event) ? window.event : event;
  13.     if (event.preventDefault)
  14.     {
  15.        msg = "Please Enter Charecters.";
  16.        alert('Invalid ' + fieldName +' ...!' + '\n\n' + msg);
  17.        event.preventDefault();
  18.  
  19.      } 
  20.     else
  21.     {
  22.        msg = "Please Enter Charecters.";
  23.        alert('Invalid ' + fieldName +' ...!' + '\n\n' + msg);
  24.        event.returnValue = false;
  25.        return false;
  26.     }
  27.    }
  28.  }

form >>>>>>>>>>>>>>>
[HTML]<body onLoad="load()">
<div style= "position:relative;top:100px;left:200px;font-size:17;color:white;border-style:none">
<form name = "backup_form" action="/pce/backupwrite">
<table class = "text_input" border="0">
<tr>
<td align="left">
Backup Location:
</td>
<td>
<input type = "text" name = "Backup_Location" id = "backup_location" onChange="checkAlpha(event,this)">
</td>[/HTML]
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Mar 14 '07

re: problem in firefox browser


Quote:

Originally Posted by muniarcot

hi,

I am facing problem with firefox2.0 browser,
Actually my problem is

i am validating a textfield using javascript.if the script return false then the cursor not focusing on failed text field...
but in IE it is happing like, if validation failed then cursor comes on wrong invalid textfield... and in this case we cant submit the form. this is actually my requirement. but in Firefox it is not happing like these...

i want IE requirement to firefox also...
please give the solution anybody...
thank you in advance.........


i also paste the code.....

Java script >>>>>>>>>>>>>>>>

function checkAlpha(event,tfield)
{
data = tfield.value;
var field = tfield.name;
fieldName = field.replace(/_/g," ");
dataRegexp = new RegExp("^([a-zA-Z/][a-zA-Z/0-9]*$)");
var matched = dataRegexp.exec(data);
if(matched != null)
return true;
else
{
event = (window.event) ? window.event : event;
if (event.preventDefault)
{
msg = "Please Enter Charecters.";
alert('Invalid ' + fieldName +' ...!' + '\n\n' + msg);
event.preventDefault();

}
else
{
msg = "Please Enter Charecters.";
alert('Invalid ' + fieldName +' ...!' + '\n\n' + msg);
event.returnValue = false;
return false;
}
}
}


form >>>>>>>>>>>>>>>
<body onLoad="load()">
<div style= "position:relative;top:100px;left:200px;font-size:17;color:white;border-style:none">
<form name = "backup_form" action="/pce/backupwrite">
<table class = "text_input" border="0">
<tr>
<td align="left">
Backup Location:
</td>
<td>
<input type = "text" name = "Backup_Location" id = "backup_location" onChange="checkAlpha(event,this)">
</td>

Java != Javascript

Moved to Javascript forum.
Familiar Sight
 
Join Date: Feb 2007
Posts: 207
#3: Mar 14 '07

re: problem in firefox browser


Quote:

Originally Posted by muniarcot

hi,

I am facing problem with firefox2.0 browser,
Actually my problem is

i am validating a textfield using javascript.if the script return false then the cursor not focusing on failed text field...

This is a common question and the answer is always the same. Alerting on blur is very poor practice, as it can cause mis-operation and difficulty abandoning a form. Alert any errors on submit, or annunciate errors in an unobtrusive way.

You're welcome in advance.
Reply