user3933050
user3933050

Reputation: 159

Input text box not recognising in IE8

I am working in a page created with the help of sharepoint .

In that page , we have one tag.

<input name="SearchBox" title="Search..." class="" id="" accessKey="S" onkeydown="" onkeypress="" onfocus="" onblur="" type="text" maxLength="2048" autocorrect="off" autocomplete="off" value="test"/>

something like the above

In IE9 and above , chrome I am fetching the value of the text box and I am passing that value to another function . It is working fine

But In IE8 , if i tried to fetch like document.getElementsByName('SearchBox')[0].value, it throwing error as "SCRIPT5007: Unable to get value of the property 'value': object is null or undefined "


I inspected the elements in developer tool of IE8. I am really surprised the input tag element is not able to inspect in IE8 . Then I opened the html in developer tool and I saw the element is missing in html file . But it is rendering in page. How come is it possible. Can anyone help me regarding this ?

We used sharepoint 2013.

Upvotes: 0

Views: 112

Answers (2)

twain
twain

Reputation: 1325

Have you tried it with JQuery?

$("input[name='SearchBox']).val();

Upvotes: 0

vengatesh rkv
vengatesh rkv

Reputation: 327

Try this code:

You should allow the blocked content:

HTML:

<input name="SearchBox" title="Search..." class="" id="txt1" accessKey="S" onkeydown="" onkeypress="" onfocus="" onblur="" type="text" maxLength="2048" autocorrect="off" autocomplete="off" value="test"/>

JS:

$(document).ready(function(){
var val=$("#txt1").val();
alert(val);
});

Upvotes: 2

Related Questions