Skip to main content
Post Undeleted by rab
deleted 513 characters in body
Source Link
rab
  • 4.2k
  • 1
  • 32
  • 42

I wrote a lengthy function, same like .ColBeseder .added a type checking :Dstring

function check( str ){   var lengthMoreThanFour = false, hasOneLower = false, hasOneUpper = false, return ( typeof str hasOneDigit== ='string') false;&&   lengthMoreThanFour = ( str.length >>= 4 ); for( var i =0; i<str.length ; i++ ){ && if ( !hasOneLower && /[a-z]/.test( str[i])str ){ hasOneLower = true;  }&& if ( !hasOneUpper && /[A-Z]/.test( str[i])str ){ hasOneUpper = true;  && } if ( !hasOneDigit && /[0-9]/.test( str[i])str ){ hasOneDigit = true; } } return lengthMoreThanFour && hasOneLower && hasOneUpper && hasOneDigit } 

and call its as check('AAA1a') , which returns a boolean

I wrote a lengthy function .. :D

function check( str ){   var lengthMoreThanFour = false, hasOneLower = false, hasOneUpper = false,  hasOneDigit = false;   lengthMoreThanFour = ( str.length > 4 ); for( var i =0; i<str.length ; i++ ){  if ( !hasOneLower && /[a-z]/.test( str[i]) ){ hasOneLower = true;  } if ( !hasOneUpper && /[A-Z]/.test( str[i]) ){ hasOneUpper = true;  } if ( !hasOneDigit && /[0-9]/.test( str[i]) ){ hasOneDigit = true; } } return lengthMoreThanFour && hasOneLower && hasOneUpper && hasOneDigit } 

and call its as check('AAA1a') , which returns a boolean

I wrote a function, same like ColBeseder .added a type checking string

function check( str ){ return ( typeof str == 'string') && ( str.length >= 4 ) && /[a-z]/.test( str ) && /[A-Z]/.test( str ) && /[0-9]/.test( str ) } 

and call its as check('AAA1a') , which returns a boolean

Post Deleted by rab
Source Link
rab
  • 4.2k
  • 1
  • 32
  • 42

I wrote a lengthy function .. :D

function check( str ){ var lengthMoreThanFour = false, hasOneLower = false, hasOneUpper = false, hasOneDigit = false; lengthMoreThanFour = ( str.length > 4 ); for( var i =0; i<str.length ; i++ ){ if ( !hasOneLower && /[a-z]/.test( str[i]) ){ hasOneLower = true; } if ( !hasOneUpper && /[A-Z]/.test( str[i]) ){ hasOneUpper = true; } if ( !hasOneDigit && /[0-9]/.test( str[i]) ){ hasOneDigit = true; } } return lengthMoreThanFour && hasOneLower && hasOneUpper && hasOneDigit } 

and call its as check('AAA1a') , which returns a boolean