function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mahesh Babu 3Mahesh Babu 3 

How to validate the password field for 'A password must contain at least one alphabet and one Numeric char'

Hello,

I am trying to validate password and showing the error message on VF page 
Validation: Password must be mixed of alphabet and numeric

My code is in below
VF page Code:
<apex:page controller="sample123class">
    <apex:form >                
        <apex:inputText html-placeholder=" Enter user name " /> <br/><br/>
        <apex:inputText html-placeholder=" Enter password " value="{!passInput}"/> <br/>  <br/>
        <apex:commandButton action="{!loginmethod}" value="login" id="set" />                                                               
    </apex:form>
</apex:page>

Controller:
public with sharing class sample123class {
    public string passInput{get;set;}
    public PageReference loginmethod() {
       if(Pattern.matches('[[0-9][a-z][A-Z]]*',passInput)){{  
            PageReference pg = new PageReference('/apex/samplehomepage');             
            return pg;
        }
        else{
            apexPages.addMessage(new ApexPages.message(ApexPages.severity.Error,'Your password code must have a mix of letters and numbers'));    
            return null;  
        }     
    }
}


Please provide the suitable 'Regex pattern' to achieve this

 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Please use below link for getting various regular expressions as per your need:
http://regexlib.com/Search.aspx?k=password&AspxAutoDetectCookieSupport=1
Mahesh Babu 3Mahesh Babu 3
Thanks for your reply Pankaj, 

I will try to use this link