i have a form in extjs and i need to do some validation tests on it on server side and return a message error but i have no clue how to do this!
i need to verify if the new added ip adress already exists
i also need to verify if it is actually a valid adress (i have a c# function that can do this)
if these conditions are ok it can be added. if not, i'd like to show an error message to the user saying what is the problem
now when i call my save button submit,i do these tests on my c# before i do the insert query, but even if those tests arent ok it still say success on the form because i dont know how to tell extjs4 there is an error
edit this is what im trying to do up to now
my form submit:
this.up('form').getForm().submit
({
url: 'AddData.ashx',
params: { action: 'addip' },
success: function (form, action) {
Ext.MessageBox.show({ title: 'Success !',
msg: 'IP added successfully<br />',
icon: Ext.MessageBox.INFO,
buttons: Ext.MessageBox.OK
});
Ext.getCmp('addipform').getForm().reset();
},
failure: function (form, action) {
switch (action.failureType) {
case Ext.form.action.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.action.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.action.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
})
inside my AddData.ashx there is a function addip() which get called when action param is 'addip' this function return :
public string addip()
{
//my queries ...
string result = new JavaScriptSerializer().Serialize("{ success:false, errors:{ text:\"The IP already exist!\", ip:\"The is not an IP !\" } }");
return result;
}
but nothing happens!