mraible commented on code in PR #243:
URL: https://github.com/apache/roller/pull/243#discussion_r4545053460
##########
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:
This regex was here before, but since it's moving: `[A-Z]{2,4}` rejects
valid addresses with longer TLDs, such as `[email protected]`,
`[email protected]` or `[email protected]`, so those users can't create
a weblog. Its maxlength of 255 also doesn't match the field's maxlength of 50.
jQuery Validate's `email: true` already validates the format, so dropping the
regex rule (or allowing TLDs of 2-63 characters) would fix it.
--
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]