+ 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'


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" />                                                               

public with sharing class sample123class {
    public string passInput{get;set;}
    public PageReference loginmethod() {
            PageReference pg = new PageReference('/apex/samplehomepage');             
            return pg;
            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


Please use below link for getting various regular expressions as per your need:
Mahesh Babu 3Mahesh Babu 3
Thanks for your reply Pankaj, 

I will try to use this link