Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to validate dynamically generated field from this javascript?
    text
    copied!<pre><code>currentg1 = 1; // This is input files added by default. maxg1 = 5; ming1 = 1; contor = 3; contor1 = 4; valuek = 2; function g1_app_child(){ if(currentg1&lt;maxg1) { var div = document.createElement("div"); div.id = 'divfiles'+currentg1; /*div.style.width = "100px"; div.style.height = "100px"; div.style.background = "red"; div.style.color = "white";*/ div.innerHTML = '&lt;a href="javascript:void();" onclick="g1_delchild()"&gt;Remove websites&lt;/a&gt;&lt;br&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on'+contor+'" value="Keywords" class="special"&gt;Keywords: &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="os'+contor+'" maxlength="200" id="keywords" class="special"&gt;ex: seo services&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="hidden" name="on'+contor1+'" value="Website" class="special"&gt;Website: &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;input type="text" name="os'+contor1+'" maxlength="200" id="website" class="special"&gt;ex: seoadsem.com&lt;/td&gt;&lt;/tr&gt;&lt;input type="hidden" name="quantity" value="'+valuek+'"&gt;&lt;/table&gt;'; document.getElementById('outer_div').appendChild(div); currentg1++; valuek++; if (contor%2) { contor1++ == contor++ + 1; } else { contor++; } contor++; contor1++; return false; } else { alert('Maximum '+maxg1+' 5 websites are allowed'); return false; } } function g1_delchild() { if(currentg1&gt;ming1) { cnt = currentg1-1; element = document.getElementById('divfiles'+cnt); element.parentNode.removeChild(element); currentg1--; return false; } else { alert('Minimum '+ming1+' Website Allowed'); return false; } } function validateForm() { "use strict"; /*global document: false */ /*jshint sub:true*/ /*jslint browser: true, devel: true */ var w = document.forms.myPayPal.os0.value; var x = document.getElementById('keywords').value; var y = document.getElementById('website').value if (x == null || x == "") { alert("Please input keywords"); document.getElementById('keywords').focus() return false; } if (y == null || y == "") { alert("Please input website"); document.getElementById('website').focus() return false; } if (w === "0") { alert("You must agree to the terms of service"); return false; } } </code></pre> <p>When i try it, it validates only the initial fields. When it is starting to validate it, doesn't go through when i click more fields and click submit. Here is the test page: <a href="http://www.seoadsem.com/full-SEO-report-for-your-website-test.html" rel="nofollow">http://www.seoadsem.com/full-SEO-report-for-your-website-test.html</a></p>
 

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