Script to enforce IP address format

Greetings,
In Acrobat XI Pro, in order to ensure the user enters a properly formatted IP address, I have the following JavaScript called from a text field's properties, Format tab using a custom format script.
// Validate IPv4 address format
var ipAdr = getField("PHYSICAL IP ADDRESS");
if (event.value!=null && event.value!="") {
var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
if (re.test(ipAdr.value) == false) {
   app.alert("Please enter a valid IPv4 address");
   event.target.setFocus();  
This appears to be working, though I am wondering:
(1) Is it ok to not have an else clause?
(2) Can the RegEx be improved?
The RegEx is trying to enforce the standard IPv4 dotted decimal notation that does not include the subnet mask.
Thanks!

Many thanks Gilad, just one quick one...
Any thoughts on the 'if' with no 'else'? Or is it just a subjective preference?

Similar Messages

  • Address formating in Script

    Hi,
    I wanted to know How the control will format the address of particular customer between ADDRESS...ENDADDRESS command.
    I wanted to know where the ADDRESS format is maintained for different countries.
    Pls let me know asap.

    Hi,
    The table is T005, field ADDRS.  The meaning of this code is held in T005A.
    Regards,
    Nick

  • Address Book - Changing the address format?

    A couple of years ago I imported all my old contacts into address book. I've now discovered that I had the address format set to USA in preferences and I'm a UK user. I've since changed the preference to UK but it this only affects new addresses that I add.
    Is there a way to change those old addresses to UK format? I've tried exporting a V card and re-importing but it doesn't change.
    TIA, Steve

    Hi Steve, and a warm welcome to the forums!
    I'd take a look at Barney-15E's Script here for converting to gb/uk...
    http://discussions.apple.com/thread.jspa?threadID=764832

  • Address formatting in Cheque printing

    I am doing an enhancement on Cheque printig to change the address format.I coded a perform to call a subroutine to which i am giving the address number and retrieving the address as ADDRESS-END ADDRESS is causing some issues .but when the subroutine is called it passes address no. in some different format( like XXXXX) rather than actual value.I debugged script and in the particular window the adress no. is displayed as XXXX.i also used CONVERSION_EXIT_ALPHA_INPUT.Any suggestion is highly appreciated.Below is piece of my code
       /: DEFINE &GV_NAME& = ' '
       /: PERFORM GETADD IN PROGRAM ZRFI_FI110_CHCK_CA
       /: USING &GV_ADR&
       /:CHANGING &GV_NAME&
       /: ENDPERFORM
    REPORT  ZRFI_FI110_CHCK_CA.
    types : gtt_itcsy type standard table of itcsy .
    *&      Form  GETADD
    form getadd tables xt_intab  type  gtt_itcsy
                       xt_outab  type  gtt_itcsy.
    data: lv_name1 type NAME1,
          lv_adrnr type ADRNR,
          lwa_input type itcsy,
          lwa_output type itcsy,
          zadrc type adrc.
    read table xt_intab into lwa_input index 1..
    lv_adrnr = lwa_input-value.     ( here i am getting value of address no. from script as XXXXXXX)
    select single * into zadrc from adrc
                                 where addrnumber = lv_adrnr  and
                                       date_to  >=  sy-datum and
                                       nation     = space.
       lv_name1 = zadrc-name1.
    read table xt_outab into lwa_output index 1.
      lwa_output-value = lv_name1.
      modify xt_outab from lwa_output index 1.
      endform.

    hi amar,
    this is my subroutine. i fetch requiredvalues like this and not using address---endaddress.
    form get_ADDRESS TABLES  in_tab STRUCTURE itcsy
                          out_tab STRUCTURE itcsy.
      DATA : STREET1 LIKE ADRC-STR_SUPPL1,
             STREET2 LIKE ADRC-STR_SUPPL2,
             STREET3 LIKE ADRC-STR_SUPPL3.
      DATA :  ZADNR LIKE REGUH-ZADNR.
      DATA : LV_ADRNR TYPE AD_ADDRNUM.
      DATA : IT_ADRC TYPE ADRC OCCURS 0 WITH HEADER LINE.
    *BREAK MTABAP.
      READ TABLE IN_TAB INDEX 1.
      CONDENSE IN_TAB-VALUE.
      MOVE IN_TAB-VALUE TO  ZADNR.
      MOVE ZADNR TO LV_ADRNR .
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = LV_ADRNR
    IMPORTING
       OUTPUT        = LV_ADRNR           .
    SELECT * FROM ADRC INTO TABLE IT_ADRC
      WHERE ADDRNUMBER  = LV_ADRNR .
      READ TABLE IT_ADRC WITH KEY ADDRNUMBER = LV_ADRNR.
      STREET1 = IT_ADRC-STR_SUPPL1.
      STREET2 = IT_ADRC-STR_SUPPL2.
      STREET3 = IT_ADRC-STR_SUPPL3.
    read table OUT_tab index 1.
    MOVE STREET1 TO OUT_TAB-VALUE.
    CONDENSE OUT_TAB-VALUE.
    MODIFY OUT_TAB INDEX 1.
    read table OUT_tab index 2.
    MOVE STREET2 TO OUT_TAB-VALUE.
    CONDENSE OUT_TAB-VALUE.
    MODIFY OUT_TAB INDEX 2.
    read table OUT_tab index 3.
    MOVE STREET3 TO OUT_TAB-VALUE.
    CONDENSE OUT_TAB-VALUE.
    MODIFY OUT_TAB INDEX 3.
    ENDFORM.
    in in sapscript , i added,
    /: DEFINE &STREET1&.
    /: DEFINE &STREET2&.
    /: DEFINE &STREET3&.
    /: PERFORM GET_ADDRESS IN PROGRAM ZRFFOUS_FORM
    /: USING &REGUH-ZADNR&.
    /: CHANGING &STREET1&.
    /: CHANGING &STREET2&.
    /: CHANGING &STREET3&.
    /: ENDPERFORM.
    A6 &SPACE(6)&&REGUH-ZNME1&               
    A6 &SPACE(6)&&REGUH-ZSTRA&
    A6 &SPACE(6)&&STREET1&
    A6 &SPACE(6)&&STREET2&&SPACE(1)&&STREET3&
    A6 &SPACE(6)&&REGUH-ZORT1&-&REGUH-ZPSTL&&ADRC-POST_CODE1&
    hope this helps u.

  • Mass-change address format in address book

    Hi Guys,
    I've recently changed from pc to mac (yay) and have imported all my contacts into address book.
    I have several hundred contacts that have mailing address in the US, and several hundred that have mailing addresses in the Netherlands and some in other parts of the world.
    I'd like to change the address formats to the appropriate ones, but so far have only been figure out how to do that one at a time, or all together.
    I can use smart groups to group the addresses I want to change together, but after that I'm stuck.
    Is there a way to change the address format from selected cards? or will I have to do this one at a time?
    Thanks for your help.
    mac mini Mac OS X (10.4.8)
    mac mini Mac OS X (10.4.8)

    Here is an Applescript you can run that will do what you want:
    property CountryCode : {missing value:"us", USA:"us", Netherlands:"nl", UK:"uk"}
    tell application "Address Book"
    repeat with aPerson in people
    set theAddresses to addresses of aPerson
    if theAddresses is not {} then
    repeat with anAddress in theAddresses
    set theCountry to country of anAddress
    set the country code of anAddress to my getCC(theCountry)
    end repeat
    end if
    end repeat
    end tell
    on getCC(aCountry)
    set s to "on run {CountryCode}" & return
    set s to s & "get " & aCountry & " of CountryCode" & return
    set s to s & "end"
    try
    run script s with parameters {CountryCode}
    on error
    return text returned of (display dialog aCountry & " not found. Enter a country code:" default answer "us" buttons {"Ok"})
    end try
    end getCC
    In the property statement, change the "us" for missing value to your default country code. Add any other countries you have to the CountryCode list. The first part, before the colon, is the Name of the country as found in your address book. The second part is the ISO country code (two characters). I found a list of ISO country codes here. That list was upper case, but the address book uses lower. If you have variants of the same country name, you can just add them all to the list.
    Note: the name of the country cannot be more than one word--I didn't want to work out another way of getting codes. However, if the script runs across a country name that is not in the list, it will ask you to enter the correct value. You can change the "us" in the getCC handler to the country code of multi-name countries in your address book to make it the default answer.
    Need help with Applescript? Just copy the code into a new Script Editor document and hit the Run (green right arrow) button. It will open the Address Book and start looking through your contacts, finding ones with addresses, and setting the country code to what you say it should be in the property CountryCode list.
    If it fails with any other errors, check the Event Log History window which may give you a clue as to what was wrong with the address it failed on. You may be able to fix the address so it continues. Otherwise, post back with the error and I may be able to figure it out.

  • Problem changing address format

    I live in Japan, and therefore have lots of Japanese addresses. When I imported these addresses into Address book, it automatically put them in 'Japan' address format (although I have UK format specified in the preferences). Japan format is more or less the opposite of UK or USA format, with post code and city first, and street address last.
    However, Japan format is only used if the address is in Japanese script. Otherwise the addresses are written in UK format. Therefore, I set about changing the formats. However, when I change the format, Address Book automatically puts the words 'United Kingdom' in the country field. I then have to change it to 'Japan'. As I have about a thousand addresses, this is pretty infuriating.
    Is there anyway to change this behaviour, so that the country is not automatically inserted?

    Unfortunately you may have to clear out the country field before changing the format.

  • My apple id is not working on icloud because it is not in email address format.   how can i change my apple id to email format so icloud can work?

    Hello - I just purchased an iPhone 4s and would like to use iCloud but my apple id is not in email address format so when i try to sign into iCloud it won't let me use my apple id.  i tried to change my apple id through my account settings but could not find a way to do that.  i found ways to change everything else in my settings but when i pushed on the edit button to change my apple id the page didn't change.  Not sure how i can get to use iCloud?  Please help.

    You change the name of your ID at https://appleid.apple.com.  See http://support.apple.com/kb/HE40.

  • How to make Address Book obey Preferences? I run MacBook Pro 4.1 laptop,  Mac OS X 10.6.8  Address Book 5.0.3 (883) Preferences set at ... General First name following Last name   Sort for Last name Address Format Canada Font size Large Phone format set a

    How to make Address Book obey Preferences?
    I run MacBook Pro 4.1 laptop,  Mac OS X 10.6.8
    Address Book 5.0.3 (883) 
    Preferences set at ...
    General
    First name following Last name 
    Sort for Last name
    Address Format Canada
    Font size Large
    Phone format set at
    +1.123.456.7890
    When application quits - it's all forgotten and it self-resets to
    unwanted configuration.

    Whenever you remove system modifications, they must be removed completely, and the only way to do that is to use the uninstallation tool, if any, provided by the third-party developers, or to follow their instructions. If the software has been incompletely removed, you may have to re-download or even reinstall it in order to finish the job.
    Here are some general guidelines. Suppose you want to remove something called “BrickYourMac.” First, consult the product's Help menu, if there is one, for instructions. Finding none there, look on the developer's website, say www.brickyourmac.com. (That may not be the actual name of the site; if necessary, search the Web for the product name.) If you don’t find anything on the website or in your search, email the developer. While you're waiting for a response, download BrickYourMac.dmg and open it. There may be an application in there such as “Uninstall BrickYourMac.” If not, open “BrickYourMac.pkg” and look for an Uninstall button.
    If you can’t remove software in any other way, you’ll have to erase your boot volume and perform a clean reinstallation of OS X. Never install any third-party software unless you're sure you know how to uninstall it; otherwise you may create problems that are very hard to solve.
    Trying to remove complex system modifications by hunting for files by name often will not work and may make the problem worse. The same goes for "utilities" that purport to remove software.

  • How to setup the From header  in fullname and email address format

    when I sent mail from the messaging express , the mail that I sent cannot show the sender in the fullname and email address format. I use webmail and other mail client . It show only email address. I don't know how to setup this . I use the SUN JES messaging server 6.0 SP1 .

    exactly so.
    in general, for any configutil setting:
    0=off=no
    1=yes=on

  • Converting Script from OTF to PDF format

    Hi Experts,
    Using FM CONVERT_OTF in SAP Script print program I am converting data of Script from OTF to PDF format but the data in PDF document srinks and looks like slightly overlapping one leter on the other, can any ony please tell me that how can I avaoid this.
    Thanks in Advance
    Best Regards
    Venkat

    Dear Venkatesh,
    I have the same scenario. I have to convert Script to PDF and then write it to FTP Server.
    Could you please provide me the code which you have used?
    Regards,
    Chaitanya A

  • Standard US Address format in Smart forms

    Hi All,
    Can any one please tell me how can we achieve standard US Address format while displaying Address.
    Thanking you in advance.
    Ragards,
    Bhanu.R

    Command ADDRESS - ENDADDRESS formats an address according to the postal standards of the destination country defined in parameter COUNTRY. the reference fields are described in structure ADRC
    Syntax
    /: ADDRESS
    write ur address between this commands
    /: ENDADRRESS

  • Scripts for changing the address of the user when they have been in the box for 6 months

    Scripts for changing the address of the user when they have been in the box for 6 months
    If users are in a folder for deactivated users and disabled users in Active Directory, and been there for 6 moths do: change email address in exchange to existing email address.old 
    Anyone have suggestions on how I can go about it?

    What is this "box"?  What is this "folder" you're asking about?  You'll likely get a better answer if you use standard terminology.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • Can I set the address format for individual contacts?

    I have some foreign friends and would like to set the address format for their individual cards correctly. I can't seem to find a way to do this. I will be taken aback if this can't be done - I think the old Claris contact product did that.
    Anyone with any answer?
    Bryan

    Hi Bryan,
    When in edit mode, can you right click on the address field and change the country format there? I'm not on a Mac at the moment to double check, but that's what you do in OS 10.4 so I'd be surprised if it were changed in 10.5.
    Edit: Here's picture to demonstrate what I'm referring to:
    !http://www.ampersandbox.com/imprint/change-address-format.jpg!

  • Preventing empty rows in address formats

    Hallo everyone!
    I'd like to know if there is a method to prevent SBO2005A from printing empty rows in the address fields when for instance there is missing county in BP addresses like this:
    I have defined an address format that goes
    Block
    County
    Street
    ZipCode | Freetext(" ") | City
    We use Block as "Name2" and County as "Name3" in master data just in case the customer wants to use additional names for his BPs.
    If I use the "Block" - field and I leave the "County" - field blank it prints an empty row between "Block" and "Street". This is not the behaviour I would like to see. In case "county" is missing I would rather see something like this in a printout:
    Block
    Street
    ZipCode | Freetext(" ") | City
    So, is there a method to force this? or any workaround?

    Hello Patryk,
    PLD does not offer the functionality to control the blank lines in an address field.  I would suggest you use a formatted search in your address field on the marketing document and have it formatted in the document itself before you print.
    Please see sample code for your requirment for the Ship to address.  If you want this to applied to the Bill to address field then you have to slight alter the query by cha
    For Shipto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'S' AND T0.Address = $[$40.0.0] AND T0.CardCode = $[$4.0.0]
    For Billto address formatting
    SELECT CASE WHEN T0.Block IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.Block + CHAR(13) + CHAR(10) ELSE '' END +
    CASE WHEN T0.County IS NOT NULL THEN + CHAR(13) + CHAR(10) + T0.County + CHAR(13) + CHAR(10) ELSE '' END +
    ISNULL(T0.Street, '') + CHAR(13) + CHAR(10) + ISNULL(T0.ZipCode, '') + '  ' + ISNULL(T0.City, '')
    FROM  [dbo].[CRD1] T0 WHERE T0.AdresType = 'B' AND T0.Address = $[$226.0.0] AND T0.CardCode = $[$4.0.0]
    Suda

  • Script o/p to pdf format

    How to modify a print program that is used to convert the script o/p in to PDF FORMAT .. give me procedure to develop & help me sdn..

    Re: script o/p to pdf format
    Hi Dara Rajesh,
    RSTXPDFT4 is using for download pdf from spool request but i like get the pdf form script output display.
    Kindly help me to do.
    Advance Thanks.

Maybe you are looking for

  • Idoc 2 file - file content conversion in receiver

    Hi, My scenario is idoc to file. if i want to use file content conversion at receiver side, so i need to create record set according to sender side data type or receiver data type? plz give some inputs reg. this. Thanks

  • Why ADF tags are not being renderered ?

    Hi, I am trying to create a jsp file with adf tags, but I am getting the following warnings in the server and as a result the tags are not renderered . Jun 3, 2008 9:02:17 AM oracle.adf.view.faces.component.UIXComponentBase _getRendererImpl WARNING:

  • Locked Queues

    Hello SDN, Sometimes message processing is not executed successfully and the error lock the queues. When we check the message status (message monitoring / SXMB_MONI) it is "scheduled for outbound processing" or "System error". We fixed the errors whe

  • Z2 release in UK?

    when will get the Z2 in UK

  • Can't install the new update? :( N8-00

    I have been trying for 30 mins now and all I get is this error ? I hope someone can help? I really want the new stuff -Jemil