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<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 = '<a href="javascript:void();" onclick="g1_delchild()">Remove websites</a><br><table><tr><td><input type="hidden" name="on'+contor+'" value="Keywords" class="special">Keywords: </td></tr><tr><td><input type="text" name="os'+contor+'" maxlength="200" id="keywords" class="special">ex: seo services</td></tr><tr><td><input type="hidden" name="on'+contor1+'" value="Website" class="special">Website: </td></tr><tr><td><input type="text" name="os'+contor1+'" maxlength="200" id="website" class="special">ex: seoadsem.com</td></tr><input type="hidden" name="quantity" value="'+valuek+'"></table>';
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>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;
}
}
시도하면 초기 필드 만 확인합니다. 유효성 검사를 시작할 때 더 많은 필드를 클릭하고 제출을 클릭해도 진행되지 않습니다. 다음은 테스트 페이지입니다. http://www.seoadsem.com/full-SEO-report-for-your-website-test.html
사용할 때 페이지에 동일한 ID를 가진 요소를 하나만 가질 수 있으며 getElementById
(첫 번째 요소를 선택 함) 둘 이상을 사용해서는 안됩니다 (대신 클래스 사용). 그러나 다음을 사용하면 현재 스크립트의 유효성을 검사 할 수 있습니다.
[].slice.call(document.querySelectorAll('#keywords')).forEach(function(keyword) {
// validate keyword here
});
id = 키워드 인 모든 요소를 선택합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다