Looks like you are using some server side language of some sort mixed with javascript.
What does txtname.ClientID actually evaluate to and what is on your page.
It is very likely that you are not selecting an actual element with the document.getElementById call.
Chrome and IE may handle this one way (return an empty string when you attempt to access value)
while Firefox may handle it another way (return null, return an error when attempting to get value from the null object, and stop processing javascript).
To see how this works, try opening up the file below in firefox. The first two attempts (when a null check is in place) will correctly report the found or not found conditions.
With the second two attempts (when a null check is not in place), the first (element found) works fine, but the second fails because null is returned by document.getElementById and firefox does not know how to continue from this error.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>CSS Reset</title>
</head>
<body>
<input id="value1" type="text" value="value1"/>
<script language="javascript">
alert('finding value1 with null check');
var element = document.getElementById('value1');
if ( element == null ){
alert('not found');
}
else{
var txtname = element.value;
alert(txtname);
}
alert('finding value2 with null check');
var element = document.getElementById('value2');
if ( element == null ){
alert('not found');
}
else{
var txtname = element.value;
alert(txtname);
}
alert('finding value1 without null check');
var txtname = document.getElementById('value1').value;
alert(txtname);
alert('finding value2 without null check');
txtname = document.getElementById('value2').value;
alert(txtname);
alert('finished');
</script>
</body>
</html>