또 하나의 거대한 양식을 만들지 만 자바 스크립트로 여러 단계로 나눕니다. 마지막 탭의 버튼 만 양식을 제출하고 다른 버튼은 다음 단계를 보여줍니다. "다음"조치 후에 약한 유효성 검증을 수행하고 양식을 제출 한 후 서버에 대한 유효성 검증을 수행 할 수 있습니다.
http://jsfiddle.net/ht227xy3/1/
<script>
function switcher(activeBlock, passiveBlocks){
document.getElementById(activeBlock).style.display='';
for (i in passiveBlocks){
if (document.getElementById(passiveBlocks[i]))
document.getElementById(passiveBlocks[i]).style.display='none';
}
return false;
}
</script>
<form onsubmit="alert('Now form submits!!!')" action="" method="post">
<div id="first" class="tab">
<h3>Step 1 of 4</h3>
<b>Field 1:</b> <input type="text" name="field1" value="" /><br />
<br />
<button type="button" onclick="switcher('second', ['first','third','fourth']);">Next</button>
</div>
<div style="display:none;" id="second" class="tab">
<h3>Step 2 of 4</h3>
<b>Alt 1:</b> <input type="text" name="alt1" value="" /><br />
<br />
<button type="button" onclick="switcher('third', ['first','second','fourth']);">Next</button>
</div>
<div style="display:none;" id="third" class="tab">
<h3>Step 3 of 4</h3>
<b>Extra 1:</b> <input type="text" name="extra1" value="" /><br />
<br />
<button type="button" onclick="switcher('fourth', ['first','second','third']);">Next</button>
</div>
<div style="display:none;" id="fourth" class="tab">
<h3>Step 4 of 4</h3>
<b>File 1:</b> <input type="file" name="file1" /><br />
<br />
<input type="submit" value="Submit" />
</div>
</form>
사용 jQuery를 또는 무언가 당신은 한 번만 양식을 보내 그래서? – Daan
1 단계만으로 좋은 양식을 작성하면 "다음"을 클릭하는 데 지루해하지 않으시겠습니까? – ViliusL
양식이 너무 길면 모든 항목을 한 번에 확인 하시겠습니까? 한 페이지 양식이 좋은 양식과 동일하지 않습니다. –