Jacob
Jacob

Reputation: 14741

Javascript Error When <!DOCTYPE html> Is Added To JSP Page

I have the following code snippet in JSP page

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.util.*,java.sql.*,javax.naming.*%>
<html>
<head>
......
.......

When I tried to add

<!DOCTYPE html>

to top of page, I am getting the following error

Unable to get value of the property 'value': object is null or undefined

What could be the reason for this and how to resolve this error?

Scripts block

<script>
function myFunc() {
    if (prod.value.length > chars) {
        prod.value = prod.value.substring(0, chars);
        alert('Exceeded');
    } 
}
</script>

Upvotes: 0

Views: 1965

Answers (1)

Dai
Dai

Reputation: 155438

Adding <!DOCTYPE html> shifts the browser into Strict Mode, which means it has narrower tolerances for common coding errors in addition to having slightly different CSS behaviour.

It sounds like you have a <script type="text/javascript"> on your page which uses an obsoleted or deprecated technique for getting input values.

I suggest using a Script Debugger (IE, Chrome, Safari and Firefox all feature script debuggers, all accessed by pressing F12) and stepping through your scripts to find the cause of the error and then fixing it yourself.

Upvotes: 1

Related Questions