<form id="form1" runat="server">, Warnings

3.2k Views Asked by At

I use this code to make my page have same height in a browser, it works, but when i check the code for mistakes, it gives me 3 warnings:

Warning:

<form> proprietary attribute "runat"

Warning:

<form> lacks"action" attribute 

Warning:

<script> inserting "type" attribute

The code I use:

<body style="overflow:hidden; margin:0">
     <form id="form1" runat="server">
     </form>
     <script language="javascript">
          function autoResizeDiv()
         {
           document.getElementById('main').style.height = window.innerHeight +'px';
        }
        window.onresize = autoResizeDiv;
         autoResizeDiv();
    </script>

Should I ignore those warnings? and as a method is it correct?

2

There are 2 best solutions below

1
On

runat="server" is asp.net specific attribute. It wont work in generic html scenario. What tech you are using for front end HTML4/5, PHP, ASP.NET

You should consider building your form tag soemthing like this (Taken from this page itself):

<form id="search" action="" method="get" > </form>

3
On

<form> proprietary attribute "runat"

runat is ASP.NET. You should be checking the output of your ASP.NET, not the server side code.

If you aren't using ASP.NET, you shouldn't be using runat

<form> lacks"action" attribute
<script> inserting "type" attribute

HTML 5 makes these attributes optional.

Either you are not using HTML 5 (in which case you probably should be) or you are using an out of date QA tool. For HTML validity try the W3C Markup Validation Service.