=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AccountController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AccountController.java 2012-10-22 14:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AccountController.java 2012-10-22 16:02:20 +0000
@@ -170,7 +170,7 @@
log.info( "Recaptcha failed with code: " + ( results.length > 0 ? results[1] : "" ) );
response.setStatus( HttpServletResponse.SC_BAD_REQUEST );
- return "The characters you entered did not match the word verification, please try again";
+ return "The characters you entered did not match the word verification, try again";
}
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-10-22 11:05:48 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-10-22 16:02:20 +0000
@@ -1336,17 +1336,6 @@
});
}
-/**
- * Formats validation messages. Used by messages.vm.
- *
- * @param text the text to format.
- * @returns the formatted text.
- */
-function validatorFormat( text )
-{
- return $.validator.format( text );
-}
-
// -----------------------------------------------------------------------------
// Message
// -----------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js 2012-10-21 12:56:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js 2012-10-22 16:02:20 +0000
@@ -564,3 +564,16 @@
}
return null;
}
+
+function validatorFormat( text ) // Custom code
+{
+ return $.validator.format( text );
+}
+
+jQuery( document ).ready( function() { // Custom code
+
+ if ( typeof( validationMessage ) !== "undefined" ) // From messages.vm
+ {
+ $.validator.setMessages( validationMessage );
+ }
+} );
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js 2012-10-22 14:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/account.js 2012-10-22 16:02:20 +0000
@@ -2,25 +2,30 @@
rules: {
firstName: {
required: true,
- rangelength: [ 1, 80 ]
+ rangelength: [ 2, 80 ]
},
surname: {
required: true,
- rangelength: [ 1, 80 ]
+ rangelength: [ 2, 80 ]
},
username: {
required: true,
- rangelength: [ 1, 80 ],
+ rangelength: [ 4, 80 ],
remote: "../../api/account/username"
},
password: {
required: true,
- rangelength: [ 1, 80 ]
+ rangelength: [ 8, 80 ],
+ password: true,
+ },
+ retypePassword: {
+ required: true,
+ equalTo: "#password",
},
email: {
required: true,
email: true,
- rangelength: [ 1, 80 ]
+ rangelength: [ 4, 80 ]
}
}
};
@@ -31,8 +36,6 @@
callback: Recaptcha.focus_response_field
} );
- $( "#recaptchaValidationField" ).hide();
-
$( "#accountForm" ).validate( {
rules: validationRules.rules,
submitHandler: accountSubmitHandler,
@@ -40,20 +43,22 @@
element.parent( "td" ).append( "
" ).append( error );
}
} );
-
- $.extend( jQuery.validator.messages, {
- required: "This field is required",
- rangelength: "Please enter a value between 1 and 80 characters long",
- email: "Please enter a valid email address"
- } );
} );
function accountSubmitHandler()
{
+ if ( $.trim( $( "#recaptcha_challenge_field" ).val() ).length == 0 ||
+ $.trim( $( "#recaptcha_response_field" ).val() ).length == 0 )
+ {
+ $( "#messageSpan" ).show().text( "Please enter a value for the word verification above" );
+
+ return false;
+ }
+
$.ajax( {
url: "../../api/account",
data: $( "#accountForm" ).serialize(),
- type: "POST",
+ type: "post",
success: function( data ) {
alert("Account created");
},
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm 2012-10-22 14:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/useraccount/account.vm 2012-10-22 16:02:20 +0000
@@ -4,7 +4,9 @@