You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ad...@apache.org on 2020/05/31 13:51:29 UTC
[roller] 01/02: Implemented: validation using the jquery validation
plugin (ROL-2156) Used validation on the Create weblog page
This is an automated email from the ASF dual-hosted git repository.
adityasharma pushed a commit to branch roller-6.0.x
in repository https://gitbox.apache.org/repos/asf/roller.git
commit bd164d6df9679a7f546b4bf8bd8da5cc2cf1fbfb
Author: Aditya Sharma <ia...@gmail.com>
AuthorDate: Mon May 11 19:45:14 2020 +0530
Implemented: validation using the jquery validation plugin (ROL-2156)
Used validation on the Create weblog page
---
app/pom.xml | 5 +++++
app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp | 14 ++++++++------
app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp | 2 ++
app/src/main/webapp/theme/scripts/roller.js | 3 +++
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/app/pom.xml b/app/pom.xml
index 5cfc229..64a2a45 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -260,6 +260,11 @@ limitations under the License.
</dependency>
<dependency>
+ <groupId>org.webjars</groupId>
+ <artifactId>jquery-validation</artifactId>
+ <version>1.19.0</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<scope>compile</scope>
diff --git a/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp b/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
index ebc9d34..0f8762e 100644
--- a/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
@@ -21,18 +21,18 @@
<br/>
-<s:form action="createWeblog!save" theme="bootstrap" cssClass="form-horizontal">
+<s:form action="createWeblog!save" theme="bootstrap" cssClass="form-horizontal validate-form">
<s:hidden name="salt"/>
<s:textfield label="%{getText('generic.name')}"
tooltip="%{getText('createWebsite.tip.name')}" onkeyup="formChanged()"
- name="bean.name" size="30" maxlength="30"/>
+ name="bean.name" size="30" maxlength="30" requiredLabel="Name is a required field" required="required"/>
<s:textfield label="%{getText('createWebsite.handle')}"
tooltip="%{getText('createWebsite.tip.handle')}"
name="bean.handle" size="30" maxlength="30"
- onkeyup="handlePreview(this)"/>
+ onkeyup="handlePreview(this)" requiredLabel="Handle is a required field" required="required"/>
<div class="form-group">
<label class="col-sm-3"></label>
@@ -99,11 +99,13 @@
previewImage('<s:property value="bean.theme"/>');
</s:else>
- formChanged()
+ // TODO Remove custom validation code
+ // formChanged()
});
function formChanged() {
- var valid = false;
+ // TODO Remove custom validation code
+ /*var valid = false;
var name = $("#createWeblog_bean_name:first").val();
var handle = $("#createWeblog_bean_handle:first").val();
@@ -117,7 +119,7 @@
saveButton.attr("disabled", false);
} else {
saveButton.attr("disabled", true);
- }
+ }*/
}
function handlePreview(handle) {
diff --git a/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp b/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp
index 8d10e2d..8a31d67 100644
--- a/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp
+++ b/app/src/main/webapp/WEB-INF/jsps/tiles/head.jsp
@@ -10,6 +10,8 @@ You can override it with your own file via WEB-INF/tiles-def.xml
<script src="<s:url value='/webjars/jquery-ui/1.12.1/jquery-ui.min.js' />"></script>
<link href="<s:url value='/webjars/jquery-ui/1.12.1/jquery-ui.css' />" rel="stylesheet" />
+<script src="<s:url value='/webjars/jquery-validation/1.19.0/jquery.validate.min.js' />"></script>
+
<link href="<s:url value='/webjars/bootstrap/3.3.7/css/bootstrap.min.css' />" rel="stylesheet" />
<link href="<s:url value='/webjars/bootstrap/3.3.7/css/bootstrap-theme.min.css' />" rel="stylesheet" />
<script src="<s:url value='/webjars/bootstrap/3.3.7/js/bootstrap.min.js' />"></script>
diff --git a/app/src/main/webapp/theme/scripts/roller.js b/app/src/main/webapp/theme/scripts/roller.js
index 1ec4976..a85adcf 100644
--- a/app/src/main/webapp/theme/scripts/roller.js
+++ b/app/src/main/webapp/theme/scripts/roller.js
@@ -210,3 +210,6 @@ function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
+$(document).ready(function () {
+ jQuery("form.validate-form").validate();
+});