Booktitle, Author가있는 양식이 있습니다. 두 필드가 비어있는 것처럼 유효성을 검사해야 필드가 필수 항목이므로 메시지를 표시해야합니다. 어떻게 할 수 있습니까? 나는 이것을 달성했다. 나는 이것에 대해 구글에서 검색했고, 아래 코드를 수정했다.jquery를 사용하여 liferay6.1에서 양식의 유효성을 검사하는 방법
<portlet>
<portlet-name>libraryportlet</portlet-name>
<icon>/icon.png</icon>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript>
<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js</header-portlet-javascript>
<header-portlet-javascript>
http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js
</header-portlet-javascript>
<footer-portlet-javascript>
/js/main.js
</footer-portlet-javascript>
<css-class-wrapper>libraryportlet-portlet</css-class-wrapper>
</portlet>
그러나 더 success.Where 내가 누군가가 따라 와요 당신에게 wrong.Can하지 않는 것입니다 :
<script>
$(document).ready(function() {
$("#_fm").validate();
var element = document.getElementById("_bookTitle");
element.className = element.className + " required";
element = document.getElementById("_author");
element.className = element.className + " required";
});
</script>
<aui:form name="fm" method="POST" action="<%=updateBookURL.toString()%>">
<aui:input name="bookTitle" label="Book Title" />
<aui:input name="author" />
<aui:button type="submit" value="Save" />
</aui:form>
과 portlet.xml의입니다.
jquery/javascript를 유효성 검사에 사용하지 말 것을 권합니다. Javascript는 클라이언트 측을 실행하며 사용 중지하기 쉽습니다. –