Email field validation function

HI,
I came across this regular expression which i am using for email validation :
var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/iCould you please explain the reg expression.Also how can i include
"-" (hyphen) and underscore to this reg expression?
Thanks a lot!
Vivek
Message was edited by:
vivek.shankar

Why not use the jakarta EmailValidator?
org.apache.commons.validator.EmailValidator
then you can say things like
public boolean vaildEmailAddress(String sEmail){
     EmailValidator emailValidator = EmailValidator.getInstance();
     return emailValidator.isValid(sEmail);
)

Similar Messages

  • Email field validation

    Please let me know the email field validation
    Regards,
    Pallavi

    I made an awesomely good email verification string:
    '^[[:alnum:]][[:alnum:]_\-\.]*@([[:alnum:]]([[:alnum:]\-]*[[:alnum:]])?\.)+[[:alpha:]]+$'Try to break it for me :)
    -UPDATE 1-
    '^[[:alnum:]]([[:alnum:]_\-\.]*[[:alnum:]])?@([[:alnum:]]([[:alnum:]\-]*[[:alnum:]])?\.)+[[:alpha:]]+$'Forgot the last character of the local part has to be alnum :)
    Argh, hyphens still break it in the local part.
    -UPDATE 2-
    '^[[:alnum:]]([-[:alnum:]_\.]*[[:alnum:]])?@([[:alnum:]]([-[:alnum:]]*[[:alnum:]])?\.)+[[:alpha:]]+$'Hah, apparently hyphens can't be escaped from...
    You have to put them at the start or end of the list.

  • Validating Emails fields in my Dialog Box

    Hi all, I want to validate emails in my dialog box. My field are automatically fill by an XML and I want to validate them. I am able to validate them when the user enter a new email but if the user do not enter a new email and hit "OK", there is no validation. Any idea? Thanks!
    var submitEmailTo = "[email protected]\rclient@somewherecom"
    var submitEmailFrom = "[email protected]"
    var patt = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/g;
    var dialog1 = {
        submitEmailTo: "",
        submitEmailFrom: "",
        submitEmailMessage: "",
        initialize: function (dialog)
            dialog.load(
                "emto": submitEmailTo
            dialog.load(
                "emfr": submitEmailFrom
        commit: function (dialog)
            var results = dialog.store();
            this.submitEmailTo = results["emto"];
            this.submitEmailFrom = results["emfr"];
            this.submitEmailMessage = results["mess"];
        emto: function (dialog)
        var data = dialog.store(["emto"])
        emtoString = data["emto"]
        emtoArray = emtoString.split("\r")
        for (var i=0;i<emtoArray.length;i++)
            if (emtoArray[i].match(patt) == null)
                    app.alert("Le courriel \"" + emtoArray[i] + "\"ne semble pas valide.", 1, 0, "Validating");
        description:
            name: "Job Information", // Dialog box title
            align_children: "align_row",
            width: 400,
            height: 200,
            elements: [
                type: "cluster",
                name: "Email Information",
                align_children: "align_right",
                elements: [
                    type: "view",
                    align_children: "align_row",
                    elements: [
                        type: "static_text",
                        name: "From (CVSC): "
                        item_id: "emfr",
                        type: "edit_text",
                        alignment: "align_left",
                        width: 400,
                        height: 20
                    type: "view",
                    align_children: "align_row",
                    elements: [
                        type: "static_text",
                        name: "To: "
                        item_id: "emto",
                        type: "edit_text",
                        multiline: true,
                        alignment: "align_left",
                        width: 400,
                        height: 30
                    type: "view",
                    align_children: "align_row",
                    elements: [
                        type: "static_text",
                        name: "mess: "
                        item_id: "emto",
                        type: "edit_text",
                        multiline: true,
                        alignment: "align_left",
                        width: 400,
                        height: 70
                    alignment: "align_right",
                    type: "ok_cancel",
                    ok_name: "Ok",
                    cancel_name: "Cancel"
    app.execDialog(dialog1)
    this.info.submitEmailTo = dialog1.submitEmailTo
    this.info.submitEmailCC = dialog1.submitEmailCC
    this.info.submitEmailMessage = dialog1.submitEmailMessage

    Actually this code is  attached to a button action. When my form is opened at first, my fields are populated and all the extra information are send to custom metadata.
    The opearator here, will hit a button  and a big dialog box appear with all the job information. You see actually only the email cluster. The idea is to help the operator to  easily build an email with copy and paste. Sometime the emails fields will be filled automatically and sometime the operator will fill them.
    The reason I go through a dialog box is I don't want the client to see to much information and the email is sent by a another application.
    My first idea was to put a validation script on the "OK" button but it seems not possible to "cancel" this action.

  • Validating Email Field

    Hi
    I am developing a form in which there is an email field which i have to enter in a textArea.
    tell me how can i check whether the entered email id is valid or not.
    Its urgent
    Thanks in advance
    Dhiraj

    In case you are using JDK version prior to 1.4 you can use following function.
    <pre>
    * Validates the structure of the Email Address. This method covers most
    * requirements of the RFC822 specification.
    * @param strEmailAddress Email Address to be validated
    * @return true if validation is successful, false otherwise
    * @see RFC822
    * @see * Online Email Validator
    public static boolean isValidEmailAddress(String strEmailAddress)
              boolean bValid = true;
              // return false if strEmailAddress is either null or empty
              if (isNullorEmpty(strEmailAddress)) {
                   return false;
              // calculate length of the email address
              int iLength = strEmailAddress.length();
              // get the first occurrence of @ char
              int iCharAtPosition = strEmailAddress.indexOf("@");
              // validation fails if @ character is not present
    if (iCharAtPosition == -1) {
         bValid = false;
              // validation fails if @ character found is in the first or last position
    else if ((iCharAtPosition == 0) || (iCharAtPosition == (iLength - 1))) {
         bValid = false;
              // validation fails if more than 1 @ character are present
    else if (strEmailAddress.indexOf("@", iCharAtPosition + 1) > -1) {
    bValid = false;
              else {
                   // traverse thru all the characters in the given email address
         for (int i = 0; i < iLength; i++) {
              // get the character at the i position
         char c = strEmailAddress.charAt(i);
         if (c == '.') {
                             // validation fails if . character found is in the first or last position
              if ((i == 0) || (i == (iLength - 1))) {
              bValid = false;
              break;
         // . character cannot come before @ character
         else if (i == (iCharAtPosition-1)) {
              bValid = false;
              break;
         // all these are invalid characters
         else if ( c > '~' || c < '!' || c == '(' || c == ')' ||
         c == '<' || c == '>' || c == '[' || c == ']' ||
         c == ',' || c == ';' || c == ':' || c == '\\' ||
         c == '"') {
                             bValid = false;
         break;
              // return the validation flag          
    return bValid;
    </pre>

  • Update address-dependent email field on save of BP

    We have a requirement to update the address-dependent email field from the address-independent email field upon saving a Business Partner.
    I've been working on the 'BUPA_ADDR_UPDATE' BADi but am having no luck with it so far. I have managed to retrieve the data in the address-independent email field using the 'BUPA_CENTRAL_GET_DETAIL' Function Module but as yet have not been able to do the update of the address-dependent email field.
    Can anyone offer any guidance please ?
    thanks,
    Malcolm.

    Hi Malcolm,
    Try using the BADI : ADDR_UPDATE.
    Email is a part of the address management, so you would need an address badi.
    BUPA_ADDR_UPDATE is a business partner badi and only has the address reference - such as address number, validity, move date, etc..it will not help in cases where you need to work with address fields such as city, country, email,etc.
    Another approach :
    Try writing your code in PARTNER_UPDATE badi. This is called after save of BP. So you can probably trigger another update on the BP's address from here..
    Hope this helps you.
    Cheers,
    Rishu.

  • Email address validation pattern

    First off, I'm using JDK 1.4.2_07. What I'm trying to do is validate email addresses with the String.matches(String pattern) function. What I'm having a problem with is coming up with the regex pattern that represents any syntactically valid email address. If someone has a regex pattern that does represent any syntactically valid email address, I would appreciate it if you posted it in a reply to this message. Thanks!
    --Ioeth                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Here is the struts implementation of email address validation:
    <validator name="email"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateEmail"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.email">
    <javascript><![CDATA[
    function validateEmail(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oEmail = new email();
    for (x in oEmail) {
    if ((form[oEmail[x][0]].type == 'text' ||
    form[oEmail[x][0]].type == 'textarea') &&
    (form[oEmail[x][0]].value.length > 0)) {
    if (!checkEmail(form[oEmail[x][0]].value)) {
    if (i == 0) {
    focusField = form[oEmail[x][0]];
    fields[i++] = oEmail[x][1];
    bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    * Reference: Sandeep V. Tamhankar ([email protected]),
    * http://javascript.internet.com
    function checkEmail(emailStr) {
    if (emailStr.length == 0) {
    return true;
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
    var matchArray=emailStr.match(emailPat);
    if (matchArray == null) {
    return false;
    var user=matchArray[1];
    var domain=matchArray[2];
    if (user.match(userPat) == null) {
    return false;
    var IPArray = domain.match(ipDomainPat);
    if (IPArray != null) {
    for (var i = 1; i <= 4; i++) {
    if (IPArray[i] > 255) {
    return false;
    return true;
    var domainArray=domain.match(domainPat);
    if (domainArray == null) {
    return false;
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if ((domArr[domArr.length-1].length < 2) ||
    (domArr[domArr.length-1].length > 3)) {
    return false;
    if (len < 2) {
    return false;
    return true;
    }]]>
    </javascript>
    </validator>

  • How to pass smtp_addr(email field) to cremas idoc while creation of vendor?

    Hi All,
    i am creating the vendors by IDOC by using CREMAS basic type CREMAS05.
    There is no email field in any of the idoc segments,as i need to pass the email address being mandatory,
    i created the Z segment and added the email field into it and then created the z extension and added this zsegment into the extension.
    Now how do i and where do i map this field so that email data is also passed while creating the vendor master.
    i have debugged the cremas Function Module IDOC_INPUT_CREDITOR and the data is getting passed segment wise,and for customer segement i.e for the zsegment there is a enhancement section where i need to pass this field,but i do not know how do i map this field and with what structure.
    Please let me know how do i handel this/or is there in other way to do it.
    Thanks.
    RJP.

    Hi,
    the email is part of the address data. It is therefore not belonging to the customer master data. So it is also not part of the DEBMAS idoctype.
    To distribute via ALE accurate customer address data, you need to distribute ADRMAS, ADR2MAS, ADR3MAS idoctypes too.
    See [note 384462|https://service.sap.com/sap/support/notes/384462] and [note 306275|https://service.sap.com/sap/support/notes/306275]
    BR
    Alain

  • Field Validation on Custom Obj. 4:  Value of one field making other Req.

    Hello All,
    I have been working on a field validation problem for a while. I have a custom Picklist on CO4. This picklist has two values YES and NO (a checkbox does not meet requirements). What I need to do is If Picklist='YES' then FieldA, FieldB, and FieldC are Required else they are not required. FieldA = Text (short), FieldB = Date, and FieldC = Currency. I've tried numerous ways to validate on Fields A, B, and C with statements like IIf(Picklist=LookupValue(Picklist,"YES"),FieldA<>NULL,FieldA) or IIf(FieldValue(Picklist)="YES",FieldA<>NULL,FieldA) etc... these were just my latest attempts at this point I'm jsut trying random things to try to get it working. I am probably using incorrect syntax (even though it passes the sytax checker). If anyone has any suggestion let me know. Also if I haven't made clear what it is I'm attempting to do let me know and I'll try to clarify.
    Thanks,
    Z

    Hi,
    if I understand correctly, you want this functionality:
    If Picklist = NO => it doesn't matter what values are contained in Field A, B and C.
    If Picklist = YES => Field A is not null and Field B is not null and Field C is not null
    To trigger the validation when the picklist value changes then you have to configure the Field Validation for the Picklist:
    [<Picklist>]=LookupValue("Picklist","NO") OR ( Len([<Field_A>])>0 AND Len([<Field_B>])>0 AND Len([<Field_C>])>0 )
    You have to put the validation also on Field_A and Field_B and Field_C, because in case of an update of , let's say, Field_B, you should prevent that Field_B is blanked.
    If someone updates only Field_B and he doesn't change the value of the Picklist, the validation expression put on the Picklist is not evaluated.
    Simona

  • Name of the table where can get the two fields Valid-From and Valid-to for

    Hi gurus
    I want name of the table where I can get the two fields Valid-From and Valid-To and their relation ship with the header table in BOM
    Regards
    Kaisar

    You can only get the Valid from date from the table STKO.
    To get the valid to date, you have to take one day less than the valid-from date of the next record for the same BOM.
    Alternatively use the Function module:
    CSAP_MAT_BOM_READ
    It will give both valid from and valid to dates in the tables parameter: T_STKO
    Regards,
    Ravi
    Edited by: Ravi Kanth Talagana on Jul 2, 2008 4:37 PM

  • Bypass Required Field Validation when needed in PDF Dynamic Form

    I faced a tricky situation, where some fields are required, but we need to allow bypass required (mandatory) validation rule when saving the form, and require to fill such fields when submitting the form. In other words, provide flexible control when to turn On / Off this feature.
    I wanted to implement a flexible solution, and I will post my findings here. Appreciate your feedback for improvements.
    Steps:
    1. Mark rquired fields as required.
    2. Specify "Empty Message" as "This field cannot be left blank", or similar.
    3. Specify "Validation Script Message" as "This field must have a proper value before submit", or similar.
    4. Create a Global Form Level Variable something like "StopTotalValidation" and default as "1" means by default, Turn Off Validation for some cases.
    5. For the fields which require this type of control, add the script (to be defined later) on the "validate" event:
    myTools.validateForRequiredField(this);
    6. Create a Script Object "myTools" and add the following script:
    function initStringFunc() {
    //call this function on Document Initialize
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,"");
    String.prototype.ltrim = function() {
        return this.replace(/^\s+/,"");
    String.prototype.rtrim = function() {
        return this.replace(/\s+$/,"");
    String.prototype.isEmpty = function() {
        return (this == null) || this.trim() == "";
    function setNodeProperty(theNode, theProperty, newValue) {
       if (theNode[theProperty] != newValue) {
            theNode[theProperty] = newValue; 
    function isNodePropertyEmpty(theNode, theProperty) {
        var result;
        if (theNode == null || theNode[theProperty] == null) {
            result = true;
        } else {
            result = theNode[theProperty].isEmpty();
        return result;
    function disableTotalValidation() {
        StopTotalValidation.value = "1";
    function enableTotalValidation() {
        StopTotalValidation.value = "0";
    function isTotalValidationOn() {
        return StopTotalValidation.value != "1";
    function isTotalValidationOff() {
        return StopTotalValidation.value == "1";
    const conRequired = "(required)";
    function validateForRequiredField(theFld) {
        // Bypass Required Field Validation when Global Validation is Off.
        var result=false;
        if (theFld) {
            if (theFld.mandatory && theFld.mandatory == "error") {
                if (myTools.isNodePropertyEmpty(theFld, "rawValue")) {
                    myTools.setNodeProperty(theFld, "rawValue", conRequired);
                if (isTotalValidationOn()) {
                    if (isNodePropertyEmpty(theFld, "rawValue") || theFld.rawValue.toLowerCase() == conRequired.toLowerCase()) {
                        result = false;
                    } else {
                        result = true;
                } else {
                    result = true;             
        } else {
            result = false;
        return result;
    7. Now, on the click of "Save" button call the function "disableTotalValidation()" and on the click of "Submit" button call the function "enableTotalValidation()".
    I have just finished implementing the above solution, and as per my initial testing, it is working fine.
    I will post this to my Google Docs workspace, and provide updates their.
    Tarek.

    Hi Tarek,
    I see what you mean in relation to clarity if you used the form variable approach. It was only a suggestion. Like so many things in LC, there is more than one way to finding a solution to a problem.
    The triple equal sign (===) is testing if the condition is equal, but to a higher standard. It is testing if the values are identical to each other. For example if you were testing if a textfield was empty, with Equality (==) you might have this:
    if (this.rawValue == null || this.rawValue == "") {
         // Some script
    If you use Identity (===) you can do the same thing with less script:
    if (this.rawValue === null) {
         // Some script
    It is also useful when testing the value of an object, but also the type (eg string, number, Boolean).
    Lastly, it can be used for non-identity (!==).
    In relation to createNode() etc, apart from John's blog, it is covered in the LC documents: http://www.adobe.com/support/documentation/en/livecycle/documentation.html. Look for the scripting guides and the guide to the XML Form Object Model.
    Good luck,
    Niall

  • How to "Hide signature field validity icon when signature is valid" in Acrobat 6 Standard?

    I know how to "hide the signature field validity icon" in Acrobat 8 Pro, but just can't seem to find where to do it in Acrobat 6 Standard.
    Thanks for any help!
         .....Sean

    Hi Sean,
    That functionality didn't exist in version 6. I got to tell you though that version 6 is way past its end-of-life and you really should be using a newer version.
    Steve

  • How to Validate Email field & Other..

    Hi,
    1. I have a requirement in which I have to check that the texinput field i.e EMail field should have @ in it. If not then I need to throw exception.
    Can anybody tell me how to check @ from VO attribute.
    2. There is another text input field in which I have to check that the input value by user should not be less than 0 and greater than 15. -- Not solved Yet
    I will do these validation on submit button.
    Please help.
    Thanks in advance.
    Ajay
    Edited by: Ajay Sharma on Apr 29, 2009 6:07 AM
    Edited by: Ajay Sharma on Apr 29, 2009 8:28 PM
    Edited by: Ajay Sharma on Apr 29, 2009 8:29 PM

    Hi,
    I am trying with this...
    public boolean validateFormat(String Item)
    boolean isAlphanumeric = false;
    Number number = null;
    if(Item != null && !"".equals(Item))
    try
    number = new Number(Item);
    catch(SQLException sqlexception)
    {System.out.println("Error in conversion"); }
    if(( number < 0) && (number > 11))
    isAlphanumeric = true;
    return isAlphanumeric;
    But I am getting error while compiling
    Error(332,21): method <(oracle.jbo.domain.Number, int) not found in class exl.oracle.apps.per.eexit.server.EmployeeAMImpl
    Error(332,37): method >(oracle.jbo.domain.Number, int) not found in class exl.oracle.apps.per.eexit.server.EmployeeAMImpl
    Thanks
    Ajay

  • How do I insert the value of an email field in the submit mailto: argument?

    I want to create a button that will redirect a PDF form to an email address entered as a field in the form.  In other words, a "return to sender" function.  The button function has a submit to URL where you can use "mailto:[email protected]".  How can I substitute the value from an email field in the form itself for the "[email protected]" value?

    You'll need to use JavaScript, and the mailDoc method in particular: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.505.html
    Get the value of the field that contains the email address and use it as the value of the cTo property. See the following for a sample script: http://forums.adobe.com/message/3553628?tstart=-1

  • Need to create a validation Function Module

    Hi,
    I need to create a Validation Function Module.
    I have a ITAB into which data comes.
    FIELD-SYMBOLS : <ITAB> TYPE ANY ,
                                  key      TYPE ANY,
                                  char  TYPE ANY.
    <ITAB> = local_file.
    there is a field KEY whose sum when becomes equal to 10.000 for every CHAR,system should show a popup in the below FM
    CALL FUNCTION 'POPUP_WITH_WARNING_ALV'
      EXPORTING
        TEXTLINE1       = LT_POPUPTEXT
      TEXTLINE2       = ' '
      TITEL           = 'Warnung'
    Please let me know if the requirement is not clear.
    Thank U very Much.

    Hi annapurna ,
    In your case even the KEY value is the most useful one right,
    If so go about this way,
    have another field flag set it when the sum of the KEY values exceeds 10.
    Loop in an internla table.
    Now the internal table will have all the data including the flag and now based on the flag (whether set or not) call the function module popup which should retrieve those matnr field where flag is set.
    Display the error message saying that the KEY value fr this matnr exceeds 10.
    Revert for further clarification.
    Thanks and Regards
    Srikanth.P

  • Field validations in HTMLB.

    Hi All,
    We have  a few issues regarding field validations in HTMLB:
    1)We have an editable cell in a tableView of the form.Field validation is done , but we are unable to set the FOCUS on this field aftert displaying the error message.we tried using PHTMLB element focusRect but it dosent works.
    2)Thers a radio button group with three radio buttons.How to make selection of a radio button mandatory , similarly how to make selection from a DDLB mandatory in the form?
    I guess using java script will be benificial as it prevents server round trips....
    Thanks in advance,
    Anubhav.

    Hi ,
    Field validations for DDLBs is done , but i didnt find accurate solution for Radio Button Group...
    1)How to check that at least one radio button is selected from the radio button group?
    2)How to set focus on DDLB after alert message?
    I tried using
    dacument.form.elementID.focus( );
    But it gives a java script error
    Function not suppoeted for the element.
    3)How to stop form from submiting after the laert message?
    I tried using
    return false();
    after the message , it works but the IE shows the message
    Done but with errors on page
    after the OnClientClick is triggered.
    and if i use
    return false;
    , the form is submited....
    Thanks,
    Anubhav.

Maybe you are looking for

  • Macbook pro to my old apple laserwriter issue

    This sounds insane. and pretty stupid, but i grew up with macs, i love them anyways i have my old personal laserwriter NTr printer that i used to use with my mac IIsi. Well the thing is i think the printer still works. all i do is print out papers an

  • Error in import table data using oracle datapump

    i am trying to import table data using oracle datapump CREATE TABLE emp_xt ( ID NUMBER, NAME VARCHAR2(30) ORGANIZATION EXTERNAL ( TYPE ORACLE_DATAPUMP DEFAULT DIRECTORY backup LOCATION ('a.dmp') it return the following error ORA-29913: error in execu

  • Washed out Color in Mountain Lion

    Has anybody else noticed, after upgrading to Mountain Lion, that an exported slice from Fireworks (CS5 in my case) is very washed out, with colors much less saturated? It is driving me crazy, I'm having to workaround by taking screenshots of my work

  • Dashboard pages

    Hi, My dashboard page has 3 section the first section has yearly prompt,yearly report second section has monthly prompt ,monthly report third has daily prompt and report when i click on my dashboard only first section should be visible that is yearly

  • Error javax.mail.NoSuchProviderException: pop3

    When my application runs within JBuilder everything works fine. But with a native executable I get the following error: javax.mail.NoSuchProviderException: pop3. The Dependencies property for JavaMail=Include Dependencies. When set to Include All the