mraible commented on code in PR #243:
URL: https://github.com/apache/roller/pull/243#discussion_r4566798963
##########
app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp:
##########
@@ -89,6 +89,27 @@
var saveButton;
$( document ).ready(function() {
+
+ jQuery("form.validate-form").validate();
+ // Added method to check valid email address and add a custom error
message
+ jQuery.validator.addMethod(
+ "regex",
+ function(value, element, regexp) {
+ if (regexp && regexp.constructor != RegExp) {
+ regexp = new RegExp(regexp);
+ } else if (regexp.global) {
+ regexp.lastIndex = 0;
+ }
+ return this.optional(element) || regexp.test(value);
+ }
+ );
+ // Applied email rules to field with class name validate-email
+ jQuery( ".validate-email" ).rules( "add", {
+ minlength: 3,
+ maxlength: 255,
+ email: true,
+ regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i
Review Comment:
Thanks for testing that. Good find that the server-side validator is the one
rejecting long TLDs. I looked at the Struts 7.3.0 jar Roller ships:
`EmailValidator` sets its pattern to end in `([a-z]{2,6})`, so anything longer
than six letters fails there. Dropping the client regex makes sense to me, as
long as the server check stays. `EmailValidator` extends `RegexFieldValidator`,
so a `<param name="regex">` on the field-validator should let Roller use a
looser pattern without waiting on Struts. I haven't tried that. Fine as a
follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]