Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation of Text field not working
    primarykey
    data
    text
    <p>I have html page with checkboxes and text fields and the JavaScript is able to validate the checkboxes but not the textfields. Can someone help as I am not sure where it is wrong </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function validator() { var c = document.getElementsByName("chk"); var k=false; for( var i=0; i&lt;c.length; i++ ) { if( c[i].checked ) { k=true; return(true); } } if(k){ return(true); } else{ alert("Select one environment"); return(false); } var ap = form.getElementById("a1"); if(ap.value == "" || ap.length == 0) { alert("Enter the path"); ap.setfocus(); return(false); } else { return(true); } var p = form.getElementById("a2"); if(p.value == "" || p.length == 0) { alert("Enter the path"); form.p.setfocus(); return(false); } return(true); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="/car.java" onsubmit="return validator(this);"&gt; &lt;br /&gt; &lt;p&gt; &lt;input name="chk" type="checkbox" /&gt;One &lt;input name="chk" type="checkbox" /&gt;Two &lt;input name="chk" type="checkbox" /&gt;Three &lt;/p&gt; &lt;br /&gt; &lt;input name="a1" id="a1" size="123" style="width: 766px; height: 21px;" type="text" /&gt; &lt;/p&gt; &lt;p&gt; &lt;input name="a2" id="a2" size="123" style="width: 766px; height: 21px;" type="text" /&gt; &lt;/p&gt; &lt;textarea cols="95" name="status" rows="11"&gt;&lt;/textarea&gt; &lt;input name="sub" size="28" style="width: 156px; height: 29px;" type="button" value="Submit" /&gt; &lt;/p&gt; &lt;/form&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. This table or related slice is empty.
    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