Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A client-side validation form written in python
- Loading branch information
Dusty Phillips
committed
Apr 3, 2012
1 parent
d37d4a0
commit 841064f
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
def setup(): | ||
validate("#registration_form", | ||
{ | ||
'confirm_password': 'The passwords do not match', | ||
'username': "I'm afraid that username is taken"}, | ||
username={ | ||
'required': True, | ||
'remote': 'user_valid.json' | ||
}, | ||
password='required', | ||
confirm_password={'equalTo': 'input[name=password]'}) | ||
|
||
|
||
@JSVar('jQuery') | ||
def validate(selector, mess=None, **kwargs): | ||
if mess == None: | ||
mess = {} | ||
jQuery(js(selector)).validate( | ||
{'rules': js(kwargs), | ||
'messages': js(mess) | ||
} | ||
) | ||
|
||
jQuery(js(setup)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- python -*- | ||
# This json response is used by the validator on | ||
# register.html | ||
from aspen import Response | ||
from trembling.auth import User | ||
|
||
^L | ||
username = request.qs.one('username') | ||
existing_user = User.objects(username=username) | ||
|
||
response = Response() | ||
if existing_user: | ||
response.body = False | ||
else: | ||
response.body = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters