php - Password validating -


i trying validate confirm passwords in php using javascript code:

if($_post['passwordfield']== $_post['confirmpassword'] && $_post['passwordfield']>='8') {     echo "succed <br>"; } else {     echo "filed <br>"; } 

it works matching 2 passwords, length of password not working. if enter password less 8 character succeeds - why this?

also, how can check password strength using javascript not using regular expressions?

you should use strlen() method length of string contained in $_post['passwordfield']. , should not check string '8'. needs like:

<?php     function ispasswordvalid($password1, $password2){         if(strlen($password1) >= 8)                if($password1 == $password2)                  return true;          return false;    } ?> 

call method 2 values post. also, use trim() strip whitespaces. ohw...and has nothing javascript.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -