Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a quick example using jquery ( quickly tested in ff 11 &amp;&amp; chrome) : </p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;GE Watch&lt;/title&gt; &lt;style type="text/css"&gt; body{ padding:0px; margin:0px; font-size:11px; color:#333; font-family:Arial; background:#efefef; text-align:center; } #content{ width:600px; padding:15px; margin:20px auto; background:#fff; border:solid 1px #ddd; text-align:left; } table{ width:100%; padding:0; margin:0; border:solid 1px #ddd; border-collapse:collapse; } tr{ padding:0; margin:0 } td{ width:80px; height:20px; padding:4px; margin:0; border:solid 1px #ebebeb; text-align:center } table#myTable td input[type="text"]{ padding:2; margin:0; display:block; border:solid 1px #ddd; } table#myTable td input[type="text"].incomplete{ border:solid 1px #ff0000; } th{ font-size:11px; border:solid 1px #ddd; background:#efefef; text-align:center; color:#999; } #addRow{ padding:3px; width:80px; text-align:center; text-decoration:none; background:#0000ff; color:#fff; margin:10px 0px; font-weight:bold; font-size:10px; display:inline-block; } #message{ color:#DB1925; padding:4px; font-size:10px; font-weight:bold; border:dotted 1px #DB1925; background:#FFBABA; display:inline-block; opacity:0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="content"&gt; &lt;a href="javascript:" id="addRow"&gt;Add row&lt;/a&gt; &lt;span id="message"&gt;Please complete inputs that are in red&lt;/span&gt; &lt;br style="clear:both"/&gt; &lt;table id="myTable"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;CHECK&lt;/th&gt; &lt;th&gt;DATE&lt;/th&gt; &lt;th&gt;HOUR&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"&gt;&lt;/script&gt; &lt;script language="javascript" type="text/javascript"&gt; var rowTemplateHTML = '&lt;tr class="dataRow"&gt;&lt;td&gt;&lt;input type="text" value=""/&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" value=""/&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" value=""/&gt;&lt;/td&gt;&lt;/tr&gt;'; $(document).ready(function(){ var $tableBody = $('#myTable'), $addRowButton = $('#addRow'), $message = $('#message'); $addRowButton.click(function(event){ event.preventDefault(); $('.incomplete').removeClass('incomplete'); addRow(); }); function addRow(){ if(previousRowNotEmpty()){ $message.css("opacity", "0"); $tableBody.append(rowTemplateHTML); }else{ //alert('please complete previous row'); $message.animate({ "opacity" : "1" }, 50); } } function previousRowNotEmpty(){ var rowComplete = true; $tableBody.find('tr.dataRow:last').find('input[type="text"]').each(function(index, input){ var $input = $(input); if($input.val() === ""){ $input.addClass('incomplete'); rowComplete = false; } }); return rowComplete; } function addFirstRow(){ $tableBody.append(rowTemplateHTML); } addFirstRow(); }) &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload