2013-09-26 1 views
0

JQuery Ui 함수 "Verfiy();를 사용하려고합니다." 양식 제출을 허용하기 전에 이름, 나이, 국가 및 날짜 필드가 채워 졌는지 확인하십시오.코드가 인식되지 않음 제출 후 Verfiy 함수를 클릭 한 후

사용자가 '제출'을 클릭 할 때 verify 함수를 호출해야하지만 다음 코드를 사용할 때 필드가 완료되었는지 여부에 관계없이 웹 페이지가 '고맙습니다'페이지로 안내됩니다. 오류 메시지가 표시되지 않습니다.

<head> 

... 

<SCRIPT LANGUAGE="JavaScript"> 
<!-- Original: Wayne Nolting ([email protected]) --> 

<!-- This script and many more are available free online at --> 
<!-- The JavaScript Source!! http://www.javascriptsource.com --> 

<!-- Begin 

function verify() { 
var themessage = "You are required to complete the following fields: "; 
if (document.form.name.value=="") { 
themessage = themessage + " - Name"; 
} 
if (document.form.age.value=="") { 
themessage = themessage + " - Age"; 
} 
if (document.form.country.value=="") { 
themessage = themessage + " - Country"; 
} 
if (document.form.date.value=="") { 
themessage = themessage + " - Date"; 
} 
//alert if fields are empty and cancel form submit 
if (themessage == "You are required to complete the following fields: ") { 
document.form.submit(); 
} 
else { 
alert(themessage); 
return false; 
    } 
} 
// End --> 
</script> 

</head> 



<body> 

<p><center> 
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br> 
by <a href="http://javascriptsource.com">The JavaScript Source</a></font> 
</center><p> 


... 

<input type="submit" value="Submit" onClick="verify()"/></div> 
<input type=reset value="Clear Form"><br> 

... 

</body> 

어떤 통찰력이라도 대단히 감사하겠습니다.

앤드류

답변

0

마크 업에는 약간의 조정이 있습니다.

<input type="submit" value="Submit" onClick="return verify()"/></div> 
+0

감사합니다.하지만 불행히도 문제가 해결되지 않습니다. 어쨌든 고맙겠습니다. –

관련 문제