UNPKG

react-password-checker

Version:
42 lines (37 loc) 2.25 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactPasswordChecker = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (global){ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var React = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); var ReactPasswordChecker = React.createClass({ displayName: 'ReactPasswordChecker', getInitialState: function getInitialState() { return { validationMessage: '' }; }, checkPassword: function checkPassword(event) { var input = event.target.value; var matchPassword = /^[a-zA-Z0-9_-]{6,18}$/; if (matchPassword.test(input)) { this.setState({ validationMessage: "Your password is valid" }); } else { this.setState({ validationMessage: "Your password needs to be 6-18 characters and contain at least a lowercase letter (a-z), number (0-9), an underscore, or a hyphen" }); } }, render: function render() { return React.createElement( 'div', null, React.createElement('input', { type: 'text', placeholder: 'Check your password', onChange: this.checkPassword }), this.state.validationMessage !== '' ? this.state.validationMessage : '' ); } }); exports['default'] = ReactPasswordChecker; module.exports = exports['default']; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}]},{},[1])(1) });