Created
December 10, 2009 17:41
-
-
Save JohnB/253511 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var user_dialog = Dlg.run({ | |
markup: [{ | |
div: {id: 'user_dialog', ui: { | |
table: [ | |
{tr: [ | |
{td: {_class:'field_name', value:'Name'}}, | |
{td: [ | |
{input: {type:'text', id:'name', size:40, | |
validation: 'cannot_be_blank'}}, | |
{span: {id: 'err_msg_for_name', _class:'err_msg'}} | |
]} | |
]}, | |
{tr: [ | |
{td: {_class:'field_name', value:'Password'}}, | |
{td: [ | |
{input: {type:'password', id:'password', size:40, | |
validation: 'password_minimum_length'}}, | |
{span: {id: 'err_msg_for_password', _class:'err_msg'}} | |
]} | |
]}, | |
{tr: [ | |
{td: {_class:'field_name', value:'Confirm Password'}}, | |
{td: [ | |
{input: {type:'password', id:'confirm_password', size:40, | |
validation: 'confirmation_must_match'}}, | |
{span: {id: 'err_msg_for_confirm_password', _class:'err_msg'}} | |
]} | |
]} | |
] | |
}} | |
}], | |
cannot_be_blank: function(field_id) { | |
var field_len = $(field_id).length; | |
if( field_len < 1 ) { | |
$('err_msg_for_'+field_id).update( 'Name cannot be blank' ) | |
} | |
}, | |
password_minimum_length: function(field_id) { | |
var field_len = $(field_id).length; | |
if( field_len < 3 ) { | |
$('err_msg_for_'+field_id).update( 'Password must be at least 3 characters' ) | |
} | |
}, | |
confirmation_must_match: function(field_id) { | |
var my_value = $(field_id).value; | |
var other_field_id = $(field_id).gsub(/confirm_/,''); | |
var other_value = $(other_field_id).value; | |
if( my_value != other_value ) { | |
$('err_msg_for_'+field_id).update( 'Must match password' ) | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment