on 11-20-2013 8:52 AM
Validations for a single screen with two button( i.e. two MBO's)? first mbo need to validate plant material storage location for second mbo validations are need for plant material storage location and customer??
Hi,
We need validations for Plant(not visible in the screen) Material and customer for inventory detail screen i.e if user clicks on below buttons without giving the input it should threw error that they are required.we have an option for mandatory but the problem is customer is not mandatory for both button , it is mandatory for only one button if we give at screen designing level it reflects for both the buttons.
Thanks in advance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Interesting. Here you go,
Add the below code inside your custom.js
// The function customBeforeMenuItemClick you can find inside custom.js
hwc.customBeforeMenuItemClick = function(screen, menuItem) {
if (screen === "Start" && menuItem === "Inventory_detail") // Here you have to give the key of your screen and the button key.
{
var form = document.forms[screen + "Form"];
if (form)
{
var cost = form.Enter_Airline_ID.value; // Enter the key of the edit box
}
if (cost==null || cost == "") //add more fields here for validation.
{
alert("Please enter the mandatory fields");
return false;
}
}
return true;
};
Thanks Midhun But Already tried the above code as per our requirement mentioned below , its not working ,its not navigating to next screen nor throwing the error(validation).
function customBeforeMenuItemClick(screen, menuItem) {
if (screen === "InventorySelection" && menuItem==="InventoryOverview") {
var form = document.forms[screen + "Form"];
if (form){
var Plant = form.Plant.value;
//var Material_m = form.Material_m.value;
var StorageLocation = form.StorageLocation.value;
//var StorageLocation = form.StorageLocation.value;
var flag=false;
//var LName = form.ExpenseTracking_create_lastName_paramKey.value;
var helpElem_Plant =document.getElementById(screen + "_Plant_help");
var helpElem_Material =document.getElementById(screen + "_Material_help");
var helpElem_StorageLocation =document.getElementById(screen + "_StorageLocation_help");
if (Plant == null ||Plant == '') {
//form.Plant_m.style.border='1px solid red';
//var helpElem =document.getElementById(screenKey + "_Plant_m_help");
setValidationText(helpElem_Plant, "<font style='color:orange'>Please enter Plant</font>");
flag=true;
}else if(Plant.length >= '5'){
setValidationText(helpElem_Plant, "<font style='color:orange'>Only 4 characters will allowed here</font>");
flag=true;
}else
return true;
};
The given code should work I think you are missing some code.
Lets debug the code. Try with only one validation.
function customBeforeMenuItemClick = function(screen, menuItem) {
if (screen === "InventorySelection" && menuItem === "InventoryOverview")
{
var form = document.forms[screen + "Form"];
if (form)
{
var cost = form.Plant.value;
}
if (cost==null || cost == "")
{
alert("Please enter the mandatory fields");
return false;
}
}
return true;
};
Check whether the above code is working. Hope you are using the write keys.
Thanks Midhun its working!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope!!!
Tried the same code its not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code given is a working one. Anyway lets debug it to find where it went wrong. Add alert ("step 1"); code inside the if loop
if (screen === "InventorySelection" && menuItem === "InventoryOverview")
and
alert ("step 2"); inside if (form)
and
alert ("step 3"); inside if (cost==null || cost == "")
Check till which code it runs. You will get this alert in the device one by one when you run the app.
Double check the keys used.
- Midhun VP
Please give complete information on the requirement so me or someone else can help you.
- Midhun VP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.