Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created January 30, 2016 22:02
Show Gist options
  • Save stevesohcot/cd48e7717b9541361021 to your computer and use it in GitHub Desktop.
Save stevesohcot/cd48e7717b9541361021 to your computer and use it in GitHub Desktop.
OmniAuth - javascript
// Show Password with checkbox
//$.toggleShowPassword({
// field: '#test1',
// control: '#test2'
//});
(function ($) {
$.toggleShowPassword = function (options) {
var settings = $.extend({
field: "#password",
control: "#toggle_show_password",
}, options);
var control = $(settings.control);
var field = $(settings.field)
control.bind('click', function () {
if (control.is(':checked')) {
field.attr('type', 'text');
} else {
field.attr('type', 'password');
}
})
};
}(jQuery));
function PwMatchConfirmPw() {
$('#identity_password_confirmation').val( $('#identity_password').val() );
return ValidateRequired();
}
function ValidateRequired() {
var OkToSubmit = true;
var AllElementsThatAreRequired = $('[data-required]');
AllElementsThatAreRequired.each(function(x){
OkToSubmit = ValidatesPresence(this) && OkToSubmit;
});
return OkToSubmit;
}
function ValidatesPresence(element) {
if ( $(element).val() =='' ) {
//$('label[for =' + element.id + ']').addClass('error_alert');
$(element).addClass('border_alert');
return false;
} else {
return true;
}
}
$(document).ready(function() {
var inputsToLowerCase = $('[data-lowercase = true]');
inputsToLowerCase.each(function(){
$(this).on('blur', function() {
this.value = this.value.toLowerCase();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment