You need to sign in to do that
Don't have an account?
Mahesh 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
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
Please use below link for getting various regular expressions as per your need:
http://regexlib.com/Search.aspx?k=password&AspxAutoDetectCookieSupport=1
I will try to use this link