Validating numeric input in applescript

I'd like to check if user has entered text with the first 2 characters as integers  (e.g. 99smith).  User names at my university are in this format.  But my first attempt does not seem to recognize the numbers. 
  display dialog "Enter CUA user name:  (like 99smith)" default answer "" giving up after 40
  set {userName, returnedButton, gaveupBoolean} to the result as list
  -->{"some text", "OK", false}
  if userName is not "" then
  # take first 2 characters for variable CHECKNAME
  set CheckName to text 1 thru 2 of userName & " --test"
  display dialog CheckName & " -- 1"
  try
  set CheckNameNumber to CheckName as number
  set isInputValid to true
  display dialog CheckName & " -- 2"
  exit repeat
  on error number errorNumber
  if (errorNumber = -1700) then
  #display dialog "INVALID INPUT. TRY AGAIN."
  display dialog "Name does not start with 2 digits  " & CheckName & " -- " & userName
  end if
  end try
  end if

Here's the core of it. I'm not sure what failure you were finding, but one thing I noticed is that you didn't test each integer separately.
You need to check to do that because an integer followed by a dot or a space will not return an error if you convert the first two characters to a number together.
display dialog "Enter user name" default answer ""
set checkname to the text 1 thru 2 of the text returned of the result
try
  set firstDigit to text 1 of checkname as number
  set secondDigit to text 2 of checkname as number
on error
  display dialog "Name does not start with two digits"
end try

Similar Messages

  • C009: Gateway Name Server TCP/IP Port has to be a numeric input

    Hi!
    I am installing a new Siebel Enterprise Server 8.1.1 on WinXP with FastTrack.
    I´m in the step of Server Configuration.
    After I have put the user SADMIN I have got the error:
    "C009: Gateway name Server TCP/IP Port has to be a numeric input".
    In the C:\sba81\ses\siebsrvr\LOG\sw_cfg_util.log I have found following:
    GenericLog     GenericError     1     000000024ac004bc:0     2009-09-28 22:29:41     Error in TransferInputValues - # of controls being sent incorrect...
    GenericLog     GenericError     1     000000024ac004bc:0     2009-09-28 22:29:41     TransferInputsToValues returned error:3611539 to SetControlValues
    GenericLog     GenericError     1     000000034ac004bc:0     2009-09-28 22:29:51     Validation failed : C009: Gateway Name Server TCP/IP Port has to be a numeric input
    GenericLog     GenericError     1     000000034ac004bc:0     2009-09-28 22:29:51     ValidateFailed for Gateway Name Server TCP/IP Port, error : C009: Gateway Name Server TCP/IP Port has to be a numeric input
    Please help me!
    How I can fix it?
    Vadim Lyulin.

    Oracle is running on a box somewhere.
    Somehow you can contact that box. You should be able to ping it using the 'ip' or a 'dns host name'.
    You use that for the host name.
    I would suggest that you use sqlplus to connect to the database first to verify that it is running, the listeners are running, that the SID is correct, that the user/pwd is correct. If you can't get sqlplus to connect to it then java never will.
    Once you do that then try it in java.

  • Validating user input in VC using javascript

    Hi All,
    I'm exploring possible solutions for validating user input and reporting error messages back to the screen for users to correct their entries. It was mentioned in one of the threads that this can be done using javascript..
    can the source code in VC be edited?? Can anyone give me pointers on how to achieve this and where to incorportate the javascript function for validation? Thanks!
    cheers
    Prachi

    Hi
    Please go through the following links :-
    Alpha-Numeric Validations
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/norecordsreturnedshalldisplayalternatemessage&
    Cheers
    Navneet

  • How to do validation of input fields

    Hi all,
              I have a rquirement to do the validation of input fields.Can anybody explain me how to go for that???Please explain in detail.U can also give me a link where i can find the tutorial for doing this.

    Hi Amit,
    What everyone has said above is correct - in the method of your action simply test for whatever condition you need to validate for.  However, the following tutorial shows you how to use Web Dynpro's Message Manager to display the messages on the screen in an easy user-friendly way:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/a%20simple%20input%20form%20with%20message%20and%20error%20service%20support.pdf">Enabling Message and Error Support</a>
    In addition, there are some validations that are done automatically depending on what you have your input fields set to - for instance, if you bind your input field to a date and a user enters words into the field instead of an actual date, it will automatically display an error message.  To learn how to turn this feature on and off, see this tutorial
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/edf6ea90-0201-0010-7696-a68662381c12">Using Validating and Non-Validating Actions</a>

  • Validation of input parameters in Oracle BI Publisher reports

    Hi
    I am new to Oracle Bi Publisher.
    In my project i am using oracle BIPfor generating simple reports.
    here i need validation for input parameters (Date field) and i want to make it (Date field) disable, so that user can select the date through the Calendar component only.
    Can anyone please provide me the solution in detail, it is urgent.

    I have the same task to validate input parameters with Oracle BI Publisher 5.6.3 running under Oracle eBS 10.5.10.2. My validation goes beyond of what I can do during parameter registration. I am using Data Templates.
    My first logical place was the before report trigger. So, I built a report trigger which returns 'false' in case the parameters are not proper. Guess what... XMLP just returns a hard-coded message
    !!Error : trigger '" + datatrigger.getName() + "' returns status as 'false'
    First of all, this is a bad style to hardcode messages visible by the user (especially during French implementation). Second of all, it is not informative at all. It would be nice to change oracle.apps.xdo.dataengine.XMLPGEN.executeTrigger() to read, for example, a message from the message stack when the trigger returns 'false' and let the user read it.
    Anyway, what I did was I built a special data group, decalred before any other data group, query like
    select my_package.my_validation fro dual
    If parameters fail the validation my PL/SQL package throws an application exception with a message. At least, in this case the error message gets available as the description of the concurrent request.
    I wish the before report trigger worked!!!

  • Default Value in Numeric Input Field in Visual Composer Application

    Hi All,
    I have developed a visual composer application which has a numeric input field for Hours.
    It is mapped to a backend module.
    We are using portal 7.31
    The problem is that the deafult value of this input field is "0", but the rquirement is to display as "0.0"
    The functionality has been tested with input values in decimals and works fine. The problem is when the screen first populates, that field should show "0.0" .
    Please advise.
    Thanks

    Hi Soumya Chanda,
    I don't know of an agreeable way around it. You could have a textual input, but then it doesn't have the numeric control behavior, plus you need to handle incorrect typing (alphanumeric notes).
    Sorry!

  • Support for Multilingual Numeral Input in JTextField swing component

    When the User Locale is changed from the regional & language options in the control panel and the standard digits are customized to a non Latin character set, all the windows applications adhere to the changes made. HTML also respects the changes in effect and displays any numeric values using the new character set, which are the national digits for many Eastern Locales such as Chinese, Arabic(Saudi Arabia), Urdu and many more. The JTextField swing component given by java, however, does not show any support to the new settings. Any numeric input is displayed in the Latin character set even when the input locale of the system is also changed respectively. Any text input for this case is correctly displayed in the desired literals and appropriate glyphs. However, unlike the AWT components, numeral input and display is not catered as per the user/developer's requirements. This behavior was first noticed in 2007, as far as i have found out, and was reported once again on the same thread in 2010. The thread is given below as a reference. No action or response has been taken. Kindly look into this matter and please let me know if this bug has been reported before and if there is any intent of providing a fix for it.
    Reference: http://www.coderanch.com/t/344075/GUI/java/Multilingual-support-JTextField
    Regards,
    Aitzaz Ahmad
    Software Engineer
    SENSYS

    I too had an itch to reply with something like this
    This is a sign of work well done!
    The WD has so strong UI abstraction, that hides client-server nature applications almost completely. If you search forum, you will even find posts where developers try to upgrade value of ProgressMeter in <b>for</b> loop )
    VS

  • InDesign CS4: change position of single column guides using numerical input?

    We can change the position of single column guides to obtain unequal columns. We simply drag the guides. But is it possible to do this more precisely, hence using a numerical input field?
    To obtain the same result, I currently create a smart guide and then align the column guide with the smart guide. This is OK, but an input field for the column guide would be quicker.
    If there is currently no better way than mine, then understand this "numerical input field for column guides" as suggestion please.
    Thanks, Michael

    We can change the position of single column guides to obtain unequal columns. We simply drag the guides. But is it possible to do this more precisely, hence using a numerical input field?
    To obtain the same result, I currently create a smart guide and then align the column guide with the smart guide. This is OK, but an input field for the column guide would be quicker.
    If there is currently no better way than mine, then understand this "numerical input field for column guides" as suggestion please.
    Thanks, Michael

  • Html INPUT for numeric input

    Hi all,
    I need a INPUT html control for numeric input, that is:
    - No alphabetic characters,
    - At the lost focus, align the number to the right and formating the number.
    How can i do this or find a component with this functionality?. I tried with a jsp tag but stay out of FORM structure.
    Thanks in advance!!
    Salvador Huertas.

    So...  Do I understand correctly that there is no real interest in fixing this BlackBerry PlayBook OS/browser bug?  I don't know about other developers or users, but it actually manages to render one of my apps to near-uselessness, and it seems like it shouldn't be that hard to correct (especially given that it wasn't always doing that) if someone actually wanted to...
    Developers and users, if this bug bugs you, look up the ticket tracking this bug at https://www.blackberry.com/jira/browse/TABLET-623  and "vote" it up.

  • Prevent numeric input

    Hi,
    how can I prevent numeric input from user in a PDF form (text) field?
    I want the user to be able to enter any character, except 0,1,2,3,4,5,6,7,8 and 9
    Without displaying an alert or a sound, I just need to diseable any numeric input.
    Thanks.

    Enter this code as the custom keystroke script of your text field:
    if (event.change) event.rc = (/\d/.test(event.change))==false;

  • Validating keyboard input data

    I am new to java and have a question regarding validating input.
    I did check the FAQ for "Validating keyboard input data" but found no help.
    I have to check that the keyboard input is only one of the following char a c,C,d,D
    Ihave tried different conditional loops and statements but cannot get it right.
    Could someone point me in the right direction.
    I am using the latest java.
    Thanx

    well i think i am close but i can't figure out why i have an endless loop or how to fix it
    System.out.print("Please enter the Costumer Type C or R: ");
    String cosTypeTemp = scan.nextLine();
    cosType = cosTypeTemp.charAt(0);
    while (cosType != 'c' || cosType != 'C' || cosType != 'd' || cosType != 'D');
    do
    costumerType = 'N';
    System.out.print("Wrong input please enter the Costumer Type c or r: ");
    cosTypeTemp = scan.nextLine();
    cosType = cosTypeTemp.charAt(0);
    while (cosType != 'c' || cosType != 'C' || cosType != 'd' || cosType != 'D');
    costumerType = cosType;
    System.out.print("Please enter the Number of basic service connections: ");
    System.out.print("Please enter the Costumer Type C or R: ");
    String cosTypeTemp = scan.nextLine();
    cosType = cosTypeTemp.charAt(0);
    while (cosType != 'c' || cosType != 'C' || cosType != 'd' || cosType != 'D');
    do
    costumerType = 'N';
    System.out.print("Wrong input please enter the Costumer Type c or r: ");
    cosTypeTemp = scan.nextLine();
    cosType = cosTypeTemp.charAt(0);
    while (cosType != 'c' || cosType != 'C' || cosType != 'd' || cosType != 'D');
    costumerType = cosType;
    System.out.print("Please enter the Number of basic service connections: ");
    numBsSrvConecs = scan.nextInt();
    when i enter the correct data ( c, C, d, D) it goes into infinite loop and never reaches the next keyboard scan for System.out.print("Please enter the Costumer Type C or R: ");

  • FM WHICH adds leading zeroes to a non numeric input

    hi i need the<b> fm name</b> which will add leading zeroes to anu non numeric input
    say
    input is <b>ABC</b>
    SO MY OUTPUT SHOULD BE
    <b>000000000000ABC</b>
    URGENT
    NEED A FUNCTIOJN MODULE NAME

    i think no fn module is there for non numeric values to add zero do like this..
    data : text(20) value 'ABC',
           len type i.
    compute len = strlen( text ).
    len = 20 - len.
    do len times.
    concatenate '0' text into text.
    enddo.
    write : / text.
    regards
    shiba dutta

  • Help with date validation on input boxes.

    I need some help with date validation on input boxes.
    What I�m trying to create is a form where a user inputs dates and then the rest of the form calculates the other dates for them.
    i.e. � A user inputs 2 dates (A & B) and then a 3rd date which is 11 weeks before date B is calculated automatically.
    Is this possible and if so how do I do it ???
    Thanks

    Hi,
    to get third date try this:
    java.util.Date bDate = ...;
    Calendar yourCalendar = new GregorianCalendar();
    yourCalendar.setTime(bDate);
    yourCalendar.roll(Calendar.WEEK_OF_YEAR, -11);
    java.util.Date cDate = yourCalendar.getTime();Regards
    Ldinka

  • Change property of numeric input

    Hi,
    I have to change the property of a numeric input. The spin buttons (up
    and down) should disapear an the border- and backgroundcolor should turn
    to transparent. But i couldn't find these properties in the property
    node.
    Does anybody know how to handle this?
    thanxs a lot,
    Max

    hello Max
    If using Labview 7, there is a property node "increment decrement visible" to hide/view the up/down arrows.
    To make trasnsparent the border, use the color tool, and to make transparent the background, use the "numeric text>>text colors" property node.
    If using other version,or want to keep the control that way, best choice is "edit>>customize control" and save it for other purposes.
    Hope it helps.
    Alipio
    "Qod natura non dat, Salmantica non praestat"

  • Numerical Input and array

    Hello, I have a labview program with a numerical input for frequency. I created an array that contain a series of numbers. How can I let the program to get each element from the array sequentially? For example, it will read the first element of the array. 2 seconds later it will read the second element so on. I try to use "index array" but it only gives me one specific element of that array. Any ideas?
    Thanks
    Message Edited by lxx on 04-20-2006 10:05 PM
    Message Edited by lxx on 04-20-2006 10:06 PM

    Hello Ixx,
    From taking a look at  your program, as far as I can tell, the
    code inside the loop is creating a pulse train, and using another
    single pulse generation task to control how long to generate the
    initial pulse train.  The Wait + (ms) VI is used to prevent the
    tasks from going directly from being started to being cleared, and they
    are a necessary part if you want your program to output as many pulses
    at each frequency that you have entered into the 'number of pulses'
    control on the front panel.  It seems that if you want to try to
    transition between these different frequencies more smoothly, you
    should generate more intermediate frequencies by increasing the
    'Samples' input of the Ramp Pattern VI.  If you want to include
    more intermediate frequencies, but want to transition from your lowest
    frequency to highest in the same amount of time, then you will have to
    generate less pulses at each frequency by lowering the value in the
    'number of pulses' control.
    Have you considered programming with NI-DAQmx functions as opposed to
    these Traditional NI-DAQ functions?  They are much easier to use
    and actually perform better in almost all applications.  NI-DAQmx
    requires that you have LabVIEW 7.0 or later, and that your DAQ device
    is new enough to support it, which you can check here.
    I hope this helps!
    Regards,
    Travis G.
    Applications Engineering
    National Instruments
    www.ni.com/support

Maybe you are looking for