

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set PIN validation with JavaScript?
You can validate pin on the basis of length and type of pin must be string etc.
Example
Following is the code −
function simpleValidationForPin(pinValues) { if (!(typeof pinValues === "string" && !~pinValues.indexOf('.') && !isNaN(Number(pinValues)) && (pinValues.length === 2 || pinValues.length === 4))) { return false; } else { return true; } } if (simpleValidationForPin("0000.00") == true) console.log("This is a valid pin") else console.log("This is not a valid pin") if (simpleValidationForPin(66) == true) console.log("This is a valid pin") else console.log("This is not valid pin") if (simpleValidationForPin("4444") == true) console.log("This is a valid pin") else console.log("This is not a valid pin") if (simpleValidationForPin("66") == true) console.log("This is a valid pin") else console.log("This is not valid pin") if (simpleValidationForPin("666") == true) console.log("This is a valid pin") else console.log("This is not a valid pin")
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo254.js.
Output
This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo254.js This is not a valid pin This is not a valid pin This is a valid pin This is a valid pin This is not a valid pin
- Related Questions & Answers
- Client side validation with HTML and without JavaScript
- Verification and Validation with Example
- How to create a password validation form with CSS and JavaScript?
- How to add form validation for empty input fields with JavaScript?
- Pin description of 6800
- Pin diagram of 8212
- RST7.5 pin in 8085
- ALE pin in 8085 Microprocessor
- Pin diagram of 8086 microprocessor
- Trap interrupt pin in 8085
- How to do basic form validation using JavaScript?
- Set the innerHTML with JavaScript
- Override HTML5 validation
- Bootstrap Validation States
- validation steve"
Advertisements