PDA

View Full Version : Field Validation


Blotus
11-17-2009, 11:51 AM
Hi,

Does anyone know how to invoke field validations before submit/save.

I have this piece of code on the form for save.

var saveBtn = {text: 'Save', icon: defaultImgPath+'Save-(16x16).gif', handler: ('click',function(){n_uidoc.save() }) }

I am trying to put a validation in the handler ,but it saves irrespective of validation.

Any help will be appreciated.

Blotus
12-10-2009, 01:50 PM
Create a button using the EXT class and on the onclick event call the validate function.

var submitBtn = {text: 'Submit , icon: defaultImgPath+'arrow_org.gif', handler: ('click',
function(){

if (Validate()) n_uidoc.save();
} //function closing
) //handler closing
} //button closing

function Validate()
{
//if(Ext.get("FieldName").dom.value=="ABC" )
//{
if(Ext.get("FieldName").dom.value=="" )
{
extMsgbox("Validation","Your Message.");

return false;
}
else
return true;
}

function extMsgbox(msgTitle,message,imgIcon){
/*
Function requires "<div id=msg></div>"
placed anywhere on the form
*/
var paragraph = Ext.get('msg');
var msgb = Ext.MessageBox.show({
title: msgTitle,
msg: message , //paragraph.dom.innerHTML,
width: 400,
buttons: Ext.MessageBox.OK,
icon: imgIcon,
animEl: paragraph
});
}