javascript validations for username

This commit is contained in:
root 2010-12-02 00:54:35 +03:00
parent 75caecc6a3
commit b1c1175c67
2 changed files with 32 additions and 0 deletions

View file

@ -1,3 +1,19 @@
:javascript
$(function() {
var Validation = {
username: {
characters: /^(|[A-Za-z0-9_]{0,32})$/,
length: [6, 32]
}
};
$("#user_username").keypress(function(evt) {
if(!Validation.username.characters.test(this.value + String.fromCharCode($
evt.preventDefault();
}
});
});
= form_for(resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :put }) do |f|
%p
= f.label :username

View file

@ -1,3 +1,19 @@
:javascript
$(function() {
var Validation = {
username: {
characters: /^(|[A-Za-z0-9_]{0,32})$/,
length: [6, 32]
}
};
$("#user_username").keypress(function(evt) {
if(!Validation.username.characters.test(this.value + String.fromCharCode($
evt.preventDefault();
}
});
});
.span-12.prepend-6.last
.floating
%h3