I have a grid which is used for editing users (permissions, name etc.).
I also have a Password field, which, in editing mode, is write-only.
Meaning- the password is not displayed, but if a user inserts a value for this field- then the password is changed.
My issue is that when editing an existing user, I obviously want the password field to be optional. But when adding a new user, I want to make this field required.
How can this be acheived?
thanks
I have a grid which is used for editing users (permissions, name etc.). I
Share
for your problem you can use different validation methods when editing and adding.
example:
function validate_add(posdata, obj) { if(posdata.PASSWORD==null || posdata.PASSWORD=="" || posdata.PASSWORD==undefined) return [false, "Please enter the pasword"];return [true, ""];
}
function validate_edit(posdata, obj)
{
//you can ignore this because you dont want to verify password
}
// in jqgrid
grid.navGrid('#pager',{add:true,addtext:'Add',edit:true,edittext:'Edit',del:true,deltext:'Del', search:true,searchtext:'Find',refresh:true}, //options
{width:700,reloadAfterSubmit:true, beforeSubmit:validate_edit}, // edit options
{width:700,reloadAfterSubmit:true, beforeSubmit:validate_add}, // add options
{}, //del options
{} //search options
);