Password Validation using Regular Expression

Please help me wit the regular expression for the password policy mentioned below:-
The password length should at least be 8 characters. It should be a combination of at least any two of the given sets.
a. Set of alphabets a-z, A-Z
b. Set of numerics 0-9
c. Set of special characters ~!@#$ etc.

function validatePassword(fieldName,minNumberOfDigits, maxNumberOfDigits) {
var alphaNumericPattern = "^[a-z0-9/_/$]{" + minNumberOfDigits + "," + maxNumberOfDigits + "}";
var regExpr = new RegExp(alphaNumericPattern,"i");
var sourceField = event != null ? event.srcElement:e.target;
if(fieldName != null && fieldName != "null" && fieldName != "undefined") {
sourceField = document.getElementById('OrdFrmsessionValidater:form1:passwordField2');
var message = "Password must be a combination of alphabets and numbers";
message = message + "\n and must be between " + minNumberOfDigits + " and " + maxNumberOfDigits + " chars.";
var sourceFieldValue = sourceField.value;
if(sourceFieldValue.length < minNumberOfDigits || sourceFieldValue.length > maxNumberOfDigits){
alert(message);
sourceField.focus();
return false;
if (!regExpr.test(sourceFieldValue)) {
alert(message);
sourceField.focus();
return false;
regExpr = new RegExp("[a-z/_/$]{1}","i");
if(!regExpr.test(sourceFieldValue)){
alert(message);
sourceField.focus();
return false;
regExpr = new RegExp("[0-9]{1}","i");
if(!regExpr.test(sourceFieldValue)){
alert(message);
sourceField.focus();
return false;
var alphaNumericPattern = "^[a-z0-9/_/$]{" + minNumberOfDigits + "," + maxNumberOfDigits + "}";

Similar Messages

  • ADF Email Validation using Regular Expression

    Hi,
    Wanted to add Email Validation VO search.
    It is working if i put
    <af:validateRegExp pattern="[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"
                                             messageDetailNoMatch="The value {1} is not a valid email address:"/>However this requires email id to be entered in Capital Letters.
    Tried with below option is not working.
                   <af:inputText value="#{bindings.xxEmail.inputValue}" label="Email"
                                          required="#{bindings.xxEmail.hints.mandatory}"
                                          columns="#{bindings.xxEmail.hints.displayWidth}"
                                          maximumLength="#{bindings.xxEmail.hints.precision}"
                                          shortDesc="#{bindings.xxEmail.hints.tooltip}" id="it5">
                                <f:validator binding="#{bindings.xxEmail.validator}"/>
                                <f:validateLength minimum="6"/>             
                                <af:validateRegExp pattern="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}"
                                             messageDetailNoMatch="The value {1} is not a valid email address:"/>
                            </af:inputText>I got above info from
    ADF Email Validation using Regular Expression
    User don't enter email id Without @ .
    Kindly suggest pattern to achive this.
    Thanks,
    jit
    Edited by: appsjit on Jan 25, 2013 7:08 PM

    The RegEx to check EMail after RFC2822
    [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?There are still some missing parts in the check as not all suffix combinations are allowed, but this is pretty good.
    Timo

  • Item Validation using Regular Expression

    Hi,
    I am trying to apply a Validation to a text field item, with the type as Regular Expression.
    The text input into the field should be in a HH:MM:SS format, ie 05:30:00 (for 5:30am).
    The text I am placing in the 'Validation Expression 2' box is:
    [0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]
    This doesn't seem to work and I get an error message when I enter text in the correct format.
    I have even tried to use other comparisons, for example:
    or
    .{8}
    but these still give me an error message.
    Anyone have any ideas?

    Thanks for your help Flavio, the Regular Expression tool is really helpful.
    When I use this tool to compare strings with my regular expression, I get output = TRUE, which means I'm getting it right, but for some reason when I copy the same Regular Expression syntax into APEX, it doesn't work.
    I try to input correct strings into the field that is validated by the Reg Expr, but it still gives me an error.
    It seems to be something I am doing wrong within the application, but I can't figure out what I'm missing.
    I am creating an Item Level Validation with details:
    Type: Regular Expression
    Validation Expression 1: P23_BUS_DAY_COVERAGE_START
    Validation Expression 2: ^(([0-1][0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9]$
    Has anyone had similar problems using regualr expression validation in APEX?

  • Password validation with regular expression

    I'm trying to use a regular expression to validate a password. I've tried a number of different regex's that seem to work elsewhere but do not work in HTML DB. This includes a couple that I wrote and that I found on regex web sites. Specifically, I'm trying to validate that a string has:
    1. at least one special character
    2. at least one numeric character
    3. no more than 6 consecutive characters
    4. has a length between 8 and 14
    Does anyone know why some regular expressions do not work in HTML DB that work elsewhere or has anyone done a regex similar to this in HTML DB.
    Thanks!
    - Brian

    I see, I will use the [0-9] instead. The expression still does not work though. I simplified the expression down to try and figure out what doesn't work and it seems like it's the "?=".
    1. I first entered the expression:
    ([:alnum:]*[0-9])
    This expression just says there must be a number and it works fine in HTML DB.
    2. I extended it to:
    ([:alnum:]*[0-9])([:alnum:]*[a-z])
    This expression says that there must be a number followed by a letter. In this example "1a" works but "a1" does not.
    3. To make it not care about the order I would normally add "?=" like so:
    (?=[:alnum:]*[0-9])(?=[:alnum:]*[a-z])
    This should work for "a1" or "1a" because the ? says the order doesn't matter. When I try this in HTML DB neither "1a" or "a1" work.
    Any ideas?
    Thanks
    - Brian

  • EMAIL VALIDATION USING REGULAR EXPRESSIONS

    Hi All,
    I am new to regular expressions and am trying to learn about them.
    As practice I am trying to develop a query to filter out invalid e-mail id's eg:-
      <some-name>.<some-name1>@gmail.com - VALID
      <some-name>_<some-name1>@gmail.com - VALID
      <some-name>@<some-name1>@gmail.com - INVALID
    Lets say the column name is EMAIL_ID
    So I have the expression to validate the email end as follows
       select email from <table-name> where REGEXP_LIKE (EMAIL,'.com$') However i have no idea (wheter it is even possible) to filter out the third email id
    on the condition that it has *2 @*
    Any help regarding this would be welcome

    I would recomend you to look at
    http://psoug.org/reference/regexp.html
    And will you find answers of your questions...
    Shortly my comment to your questions...
    1. [A-Za-z0-9._%+-]Here why is %+- included in the pattern?
    Are they parts of a valid email-id?[char] Indicates a character list; most metacharacters inside a character list are understood as literals, with the exception of character classes, and the ^ and - metacharacters. Yes they are a part of valid email.
    2 +@What is this part doing?
    Is + some kind of concatenate operator to help you combine various expressions?+ is means that Character before Match 1 or more times. Your statement before "[A-Za-z0-9._%+-]" must be exist.
    3 \.Is this used to validate the . as in .com ? Point (.) by himself means One character (whenever which one). By typing \. you want to see exactly point.. \ "takes" from point "command power" and point(.) become simple character.
    4 {2,4}
    Emails end in .com then what is the use of putting this range {2,4}?{m, n}     Match at least m times but no more than n times.
    You want characters after pount in range 2 and 4. i.e. ru, com, az, net and so on...
    Hope this was helpfull for you...

  • Email validation using Regular Expression.

    Hi,
    I am in need of using a regular expression for email valiatino. ^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$ which is gotten from http://www.regular-expressions.info/email.html .
    This works fine in a regular expression test tool http://regexpal.com/ , but when I use in Oracle, it does not.
    DECLARE
    v_exp VARCHAR2(4000);
    BEGIN
       --v_exp := '^[a-z0-9!#$%&''*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$';
       v_exp := '^[a-z0-9!#\$%&''*+/=?\^_`{|}~-]+(?:\.[a-z0-9!#\$%&''*+/=?\^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$';
       dbms_output.put_line(v_exp);
       FOR v_rec IN (
          with test_data as
    ( select '[email protected]'     as val from dual union all
      select '[email protected]'       as val from dual union all
      select 'ad{[email protected]' as val from dual union ALL
      select '[email protected]' as val from dual union all 
      select '[email protected]' as val from dual union all 
      select '[email protected]'      as val from dual union all
      select 'no#good'                  as val from dual
    select
      val ,
      case
        when
          regexp_like
          (val, v_exp,'i') then 'Y'
        else 'N'
        end
        as good
    from test_data ) LOOP
       dbms_output.put_line(v_rec.val||', '||v_rec.good);
    END LOOP;  
    END;   and the results are
    [email protected], N
    [email protected], N
    ad{[email protected], N
    [email protected], N
    [email protected], N
    [email protected], N
    no#good, N
    The expected result should be Y for all but for the last two.
    I am not sure why it is not working in Oracle.
    Can any body please help me to find the mistake and to have it correctly?
    Advance Thanks,
    Natarajan
    Edited by: Nattu on Dec 4, 2012 1:31 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Try this regular expression:
    >> ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
    >> [email protected], *Y*
    >> [email protected], *Y*
    >> ad{[email protected], N
    >> [email protected], *Y*
    >> [email protected], *Y*
    >> [email protected], N
    >> no#good, N
    [Using a regular expression to validate an email address|http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address]
    Edited by: stefan nebesnak on 4.12.2012 2:25                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using regular expressions for validating time fields

    Similar to my problem with converting a big chunk of validation into smaller chunks of functions I am trying to use Regular Expressions to handle the validation of many, many time fields in a flexible working time sheet.
    I have a set of FormCalc scripts to calculate the various values for days, hours and the gain/loss of hours over a four week period. For these scripts to work the time format must be in HH:MM.
    Accessibility guidelines nix any use of message box pop ups so I wanted to get around this by having a hidden/visible field with warning text but can't get it to work.
    So far I have:
    var r = new RegExp(); // Create a new Regular Expression Object
    r.compile ("^[00-99]:\\] + [00-59]");
    var result = r.test(this.rawValue);
    if (result == true){
    true;
    form1.flow.page.parent.part2.part2body.errorMessage.presence = "visible";
    else (result == false){
    false;
    form1.flow.page.parent.part2.part2body.errorMessage.presence = "hidden";
    Any help would be appreciated!

    Date and time fields are tricky because you have to consider the formattedValue versus the rawValue. If I am going to use regular expressions to do validation I find it easier to make them text fields and ignore the time patterns (formattedValue). Something like this works (as far as my very brief testing goes) for 24 hour time where time format is HH:MM.
    // form1.page1.subform1.time_::exit - (JavaScript, client)
    var error = false;
    form1.page1.subform1.errorMsg.rawValue = "";
    if (!(this.isNull)) {
      var time_ = this.rawValue;
      if (time_.length != 5) {
        error = true;
      else {
        var regExp = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
        if (!(regExp.test(time_))) {
          error = true;
    if (error == true) {
      form1.page1.subform1.errorMsg.rawValue = "The time must be in the format HH:MM where HH is 00-23 and MM is 00-59.";
      form1.page1.subform1.errorMsg.presence = "visible";
    Steve

  • Using regular expressions for validation in i18n

    Can we use regular expressions for validation of inputs in a java application taking care of i18N aspects too. Zip code for different locales are different. Can we use regular expressions to validate zipcode inputs from different locales

    hi,
    For that shall i have to create individual patterns for matching the inputs from different locales or a single pattern will do in the case of validating phone nos. around the world, zip codes etc. In case different patterns are required, programmer should have a konwledge of difference in patters for different locales.
    regards
    sdas

  • Checking valid e-mail's using Regular expressions

    Hey buddies ,
    I desperately need some help here. I need to develop a generic method that wiull use regular expressions and patterns to validate an e-mail.
    Does anyonw have any idea on how to do this. And if possible please share some code with me.
    Thanks a lot

    You can do regular expresions in java using java.util.regex.*:
    import java.util.regex.*;
       Pattern p = Pattern.compile("\\S++\\s++");
       Matcher m = p.matcher(sInputLine);
       if(m.find()){
          sUser = m.group().trim();
       }For more info on regular expressions in java, check out the javadocs:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html

  • Date Validation (yyyy/MM/dd) Using Regular Expression

    Hi Friends,
    I want to validate date entered by user in yyyy/MM/dd format and for this I want to use Regular Expressions only. Also is there any tool that can be used to generate Regular Expression (for Win2000, Win NT)?
    Regards,
    Himanshu Rathore

    try this
    public class Test
         public static void main(String [] args)
              String regex = "\\d{4}/[01]\\d/[0-3]\\d";
              System.out.println("2003/12/11".matches(regex));
              System.out.println("2djd/kj3".matches(regex));
              System.out.println("22/12/12".matches(regex));
              System.out.println("2003/23/05".matches(regex));
              System.out.println("1999/12/51".matches(regex));
              System.out.println("2007/05/07".matches(regex));
    }i'm not able to try on it because i only have jdk1.3.1 installed on my computer and these codes
    required j2sdk1.4

  • How to use Regular expression

    Hi,
    I have a file that contains this format (separated by ;(semicolon) ):
    user id;user name;email address;password;integer;list of integer(separated by ,(comma))
    below is the example data :
    abc;Abc;[email protected];password1;1;1,2
    def;Def;[email protected];password;2;1,2,3
    ghi;Ghi;[email protected];password;2;1
    my question is how to verify the valid input for each row using regular expression..? TQ

    @Op. Doing a correct validation of e-mailaddresses
    is very hard using regular expressions (doingbasic
    validation is however easy)
    http://www.regular-expressions.info/email.html
    I like the RFC 822 compliant regexp :)

  • How to define a regular expression using  regular expressions

    Hi,
    I am looking for some regular expression pattern which will identify a regular expression.
    Also, is it possible to know how does the compile method of Pattern class in java.util.regex package work when it is given a String containing a regex. ie. is there any mechanism to validate regular expression using regular expression pattern.
    Regards,
    Abhisek

    I am looking for some regular expression pattern which will identify a regular
    expression. Also, is it possible to know how does the compile method of
    Pattern class in java.util.regex package work when it is given a String
    containing a regex. ie. is there any mechanism to validate regular
    expression using regular expression pattern.It is impossble to recognize an (in)valid regular expression string using a
    regular expression. Google for 'pumping lemma' for a formal proof.
    kind regards,
    Jos

  • Procedure using regular expression

    How to write a procedure using regular expression where i pass a string as input
    The procedure should check whether it is a valid email address or not
    Please help me

    Hello,
    perhaps you don't need to code it, because it's already there.
    When you use the database to send your mails it or the appropriate package throws the exception
    ORA-29279: Permanenter SMTP-Fehler: 501 5.5.4 Invalid Address
    When you just need a procedure to check it you can write a wrapper for a java function.
    import javax.mail.internet.*;
    import oracle.sql.NUMBER;
    public class mail_utility {
      public static NUMBER validate_address(String rfc822Address) {
        int rc = 0;
        try {
          InternetAddress ia = new InternetAddress(rfc822Address);
          rc = 1;
        } catch (AddressException ae) {
          rc = 0;
        } catch (Exception e) {
          rc = -1;
        } finally {
          return new NUMBER(rc);
    CREATE OR REPLACE  FUNCTION VALIDATE_ADDRESS (p_address in varchar2)
    return number
    as language java name
      'mail_utility.validate_address(java.lang.String) return oracle.sql.NUMBER';I think i've got it from the forum but i don't remember from whom.
    Bernd

  • Field validation by regular expressions?

    Hi everyone,
    I just started with SoD and I'd like to ensure that some field values consists of alphabetic characters only (FirstName, LastName...). I failed to create an adequate expression. Is there a possibility to use regular expressions?
    TIA
    Michael

    quote:
    Originally posted by:
    Luckbox72
    The problem is not the Regex. I have tested 3 or 4 different
    versions that all work on the many different test sites. The
    problem is it that the validation does not seem to work. I have
    changed the patter to only allow NA and I can still type anything
    into the text box. Is there some issue with useing Regex as your
    validation?
    Bear in mind that by default validation does not occur until
    the user attempts to submit the form. If you are trying to control
    the characters that the user can enter into the textbox, as opposed
    to validating what they have entered, you will need to provide your
    own javascript validation.

  • Help in query using regular expression

    HI,
    I need a help to get the below output using regular expression query. Please help me.
    SELECT REGEXP_SUBSTR ('PWRPKG(P/W+P/L+CC)', '[^+]+', 1, lvl) val, lvl
    FROM DUAL,(SELECT LEVEL lvl FROM DUAL
    CONNECT BY LEVEL <=(SELECT MAX ( LENGTH ('PWRPKG(P/W+P/L+CC)') - LENGTH (REPLACE ('PWRPKG(P/W+P/L+CC)','+',NULL))+ 1) FROM DUAL));
    I need the output as
    correct result:
    ==============
    val lvl
    P/W 1
    P/L 2
    CC 3
    But i tried the above it is not coming the above result. Please help me where i did a mistake.
    Thanks in advance

    Frank gave you a solution in your other thread. You could simplify it if you are on 11g:
    SQL> select * from table_x
      2  /
    TXT
    TECHPKG(INTELLI CC+FRT SONAR)
    PWRPKG(P/W+P/L+CC)
    select  txt,
            regexp_substr(
                          txt,
                          '(.*\()*([^+)]+)',
                          1,
                          column_value,
                          null,
                          2
                         ) element,
            column_value element_number
      from  table_x,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= regexp_count(txt,'\+') + 1
                       as sys.OdciNumberList
      order by rowid,
               column_value
    TXT                                      ELEMENT    ELEMENT_NUMBER
    TECHPKG(INTELLI CC+FRT SONAR)            INTELLI CC              1
    TECHPKG(INTELLI CC+FRT SONAR)            FRT SONAR               2
    PWRPKG(P/W+P/L+CC)                       P/W                     1
    PWRPKG(P/W+P/L+CC)                       P/L                     2
    PWRPKG(P/W+P/L+CC)                       CC                      3
    SQL>  SY.

Maybe you are looking for

  • No Longer Able To Delete Songs, Permanently. 9.0.3

    I updated to iTunes 9.0.3 yesterday. Today I somehow realized the song files i was deleting, were still in my iTunes folders. I can't necessarily blame the update because I am not sure how long this has been going on. However, I suspect I inspected b

  • Adobe haven't responded to my serial number case!! Photoshop CS4 Extended Student Edition

    Hi - I bought the student edition of Photoshop CS4 a few weeks ago. I registered on here and sent of my case to get a serial number on 21st June. A notification confirmed I had done what was required and said I would receive a reply, and therefore my

  • Can I install Airdrop on my 24" Imac 2.66 ghz?

    Aloha- I bought my Imac right when the new 21" and 27" models came out from the apple refurbished page so I know this was the last 24" model to ever come out even though it wasn't the most powerful. Can it install airdrop when I get Lion? Mahalo for

  • Website doesn't display correctly, some areas cut off

    All pages of my website cut off some text at the top and bottom. This does not happen with any other web pages I browse! The site was created by our developer and based on a Themeforest theme (from Envato) called Franklin Crowdfunding. Interestingly,

  • Variable Selection Screen in WorkBook

    Hi,    I have an workbook with variable screen, it is executing fine in my system, but it is executing without variable screen in my user's system. So I want to provide the variable screen selection in all the systems, Please provide solutions. Note: