Skip to content

Instantly share code, notes, and snippets.

@deepakkadarivel
Created October 19, 2018 09:21
Show Gist options
  • Save deepakkadarivel/158fb8eb0dfb6788a2e663d401f270fa to your computer and use it in GitHub Desktop.
Save deepakkadarivel/158fb8eb0dfb6788a2e663d401f270fa to your computer and use it in GitHub Desktop.
Validation logic check. [add your bin description] // source https://jsbin.com/gelidak
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Validation logic check.</title>
</head>
<body>
<script id="jsbin-javascript">
function minLength(min, value) {
return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
}
function minLengthNew(min, value) {
return (value && value.toString().length < min) ? 'invalid' : undefined;
}
console.log(minLength(3, '12'));
console.log(minLength(3));
console.log(minLengthNew(3, '12'));
console.log(minLengthNew(3));
</script>
<script id="jsbin-source-javascript" type="text/javascript">function minLength(min, value) {
return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
}
function minLengthNew(min, value) {
return (value && value.toString().length < min) ? 'invalid' : undefined;
}
console.log(minLength(3, '12'));
console.log(minLength(3));
console.log(minLengthNew(3, '12'));
console.log(minLengthNew(3));</script></body>
</html>
function minLength(min, value) {
return ((value && value.toString().length >= min) || !value) ? undefined : 'invalid';
}
function minLengthNew(min, value) {
return (value && value.toString().length < min) ? 'invalid' : undefined;
}
console.log(minLength(3, '12'));
console.log(minLength(3));
console.log(minLengthNew(3, '12'));
console.log(minLengthNew(3));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment