Q:

Validating Text Boxes from javascript dos not work in any browser but work in IE

I have a controls of type textbox that i have added property to it InputType
and made javascript file to validate the input text from the textbox
here the code of the text
<tc1:AppTextBox ID="txtAccNo" runat="server" InputType="Integer" IsPrimary="true"
IsDatabaseField="true" AllowNull="true">
</tc1:AppTextBox>

here the code of my javascript
function DoControlBlure(obj) {
var numVal = obj.value * 1;   //To Convert String Value of obj.value to numeric Value
var bRes = true;
if (obj) {
if (obj.type == "text") {
if (obj.InputType.toUpperCase() == "INTEGER" || obj.InputType.toUpperCase() ==DOUBLE") {
alert('obj.InputType');}}}}

in IE return the actual input type that i made but in any other browser it alert undefind
it works fine in IE but in google chrome or firefox it dose not work at all

A:

You should be using getAttribute to get non-standard attribtues of DOM Elements in a cross-browser-safe manner:
<input id="test" InputType="test" />

<script>
  window.onload = function(){
    var input = document.getElementById('test');
    alert(input.InputType); /// will work in IE, fail in others
    alert(input.inputtype); /// will fail in all I think?
    alert(input.getAttribute('InputType')); /// will work in all
    alert(input.getAttribute('inputtype')); /// should work in all
  }
</script>

