BUGFIX #3418: Remove jQuery coupling from Email field focus, and only include email focus when validation is enabled

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@72557 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-03-06 02:23:37 +00:00
parent 9919f5383e
commit 4e28b8d865

View File

@ -37,15 +37,6 @@ class MemberLoginForm extends LoginForm {
Requirements::css($customCSS);
}
// Focus on the email input when the page is loaded
Requirements::customScript("
(function($){
$(document).ready(function() {
$('#Email input').focus();
});
})(jQuery);
");
if(isset($_REQUEST['BackURL'])) {
$backURL = $_REQUEST['BackURL'];
} else {
@ -85,6 +76,18 @@ class MemberLoginForm extends LoginForm {
}
parent::__construct($controller, $name, $fields, $actions);
// Focus on the email input when the page is loaded
// Only include this if other form JS validation is enabled
if($this->getValidator()->getJavascriptValidationHandler() != 'none') {
Requirements::customScript(<<<JS
(function() {
var el = document.getElementById("MemberLoginForm_LoginForm_Email");
if(el && el.focus) el.focus();
})();
JS
);
}
}
/**