PDA

View Full Version : form validation displaying serverside error



topcoder1
3 Aug 2007, 12:07 PM
I have a login form that I submit to the server for validation, after server validates it, if there's an error, server echos the error back in json format, triggers the javascript callback function Failure. Now is there an easy way to display the error on the form itself? Of course I can create a simple div in the form for this purpose, but does the ext Form already have a way to display server side error? I am using alert to display the error for now.

javascript code
form.addButton('Login', function(){
form.submit({
waitMsg:'Please Wait...',
reset:true,
success:Login.Success,
failure:Login.Failure,
scope:Login
});
}, form);
form.render('login-form');
dialog.on('show', function(){form.items.item(0).focus();});
dialog.show(document.body.getElementsByTagName('div')[0]);
},
Success: function(f,a){
//alert("result " + a.result);


dialog.destroy(true);

},
Failure:function(form, action){
alert(action.result.errorMessage);
}

devnull
3 Aug 2007, 12:36 PM
I dont think it supports displaying an error message directly, but you can return error messages for individual fields which will get displayed like any other field validation messages.
the "XML Form" demo in the examples and demos in the documentation area does this.