Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Validating a value based on a functions

$
0
0

I created a function that basically is a an array that associates a numerical value to a string

 

function myValidation(mip)

{

var text = "";

var mipCodes = {
"A100" : "String 1",
"A101" : "String 2",
"A102" : "String 3",
"A103" : "String 4",
"A104" : "String 5"

}

 

//When a MIP code is entered
if (mip != "") text = mipCodes[mip];

return text;
}

 

I want to use this function as a validation script, like if the function return an empty string (meaning the value was not found in the array), the value is not commited.

 

I tried this validation script:

if (text == "") event.rc = false;

 

When this will work, I'll need to add other validation functions in a row before a value is commited.


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>