Validate numbers and characters in a form field.

Hi all

I have created a form and in it, there are e-mail and phone number fields.

I found http://forums.adobe.com/thread/857974

to be really useful to help me validate my email field.

Then I tried to tweak for the phone number field I need to allow only characters 1234567890 +)

As you can see, the number of his just and + (). How to restrict the field to only accept characters?

I tried but it failed:

Custom text field validation script

(function () {}

var val = String (event.target.value);

Do nothing if the field is empty

If (! val) return;

If the value is not a phone number valid...

If (! val.match (/ \ +?)) [ 0-9\(\)]*/)) {

.. .that the user knows that the value is not a valid phone number...

App.Alert ("Please enter a phone number, for example + 012 (3) 123123123", 3 ");

.. .and set the focus on this field

event.target.setFocus ();

}

})();

But it does not work. Sigh.

I have 0 training in computer language (I am a biologist, and this is a form for doctors to fill with data of patients) and would appreciate your help in getting the work phone field validation.

Thank you!

Try this script:

function validate (telephone) {}

var regex = /^(\+) ((?: [0-9]?) 6.14 {[0-9]) $/;

If (regex.test (phone)) {}

Valid international phone number

return the RegExp. $1 + "" + RegExp. $2;

} else {}

Invalid international phone number

Return ' ';

}

}

If (event.value! = "") {}

Event.Value = validate (event.value);

If (event.value == "") {}

App.Alert ("Please enter a valid + 1 international phone 12(3) 123123 number\n (12312)") ", 1, 0);

Event.RC = false;

}

} / / end of non-null field value

Note it is a validation script and runs only when you leave a field. If you want to check hits then you will need to use the custom keystroke script and you can use this code as a starting point, but you will need change the format RegExp string to test every keystroke as it is typed.

Tags: Acrobat

Similar Questions

  • How to allow the addition of attachments and more filled in form fields and signing existing signature field

    How do to allow the addition of attachments and more filled in form fields and signing of signature field when creating a secure pdf document?

    You must allow commenting as well. Reader users will be able to add attachments as comments. You can also use JavaScript with Player 11 and DC to automate the process somewhat.

    If you need users of Reader in order to add attachments as Acrobat can, you need to add the right of use of file attachments, but you can't do that with Acrobat.

  • Can any body help to get a script that can generate the sequence (length 3) with a combination of numbers and characters example: T11... TA1... TZ9... then on

    Can any body help to get a script that can generate the sequence (length 3) with a combination of numbers and characters example: T11... TA1... TZ9... then on

    With the help of the clause type

    Select sqnc

    from (select sqnc

    from (select 'T00"sqnc, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ordr

    of the double

    )

    model

    size of (0 I)

    measures (sqnc, ordr, length (ordr) len)

    rules iterate (1300) until (instr(sqnc[iteration_number],'~')! = 0)

    (sqnc [iteration_number] = case when sqnc [cv (i) - 1] is null

    then sqnc [0]

    of another substr (sqnc [iteration_number - 1], 1, 1) |

    -case when substr (sqnc [iteration_number - 1], 2, 1)<=>

    so when business substr (sqnc [iteration_number - 1], 3, 1)<>

    then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)), 1)

    of another nvl (substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 2, 1)) + 1.1),'~ ')

    end

    end |

    -case when substr (sqnc [iteration_number - 1], 3, 1)<>

    then substr (ordr [0], instr (ordr [0], substr (sqnc [iteration_number - 1], 3, 1)) + 1.1)

    else ' 0'

    end

    end

    )

    )

    where instr(sqnc,'~') = 0

    Concerning

    Etbin

  • Remove the spaces and special characters to a form field

    Hello

    I am tragically new to all this, but I'm trying to create a form in Adobe Acrobat 9.  I am trying to use a custom script Format to make entries in a form field and automatically remove the spaces and special characters (hyphens specifically).  For example, if a user 'RAN - 99 06' entries I want to change it to "RAN9906."  I found this script that does not allow users to input special characters

    If (! event.willCommit) {}


    Event.change = event.change.replace (/ [------$# ~ %------*------*------^-------------(\)------+=------[\]------{\}; \ "\ <>\ \?"]) \ | \\\ !] /g, "");

    }

    And it's OK, but I can't understand how to prohibit the spaces.  In addition, the perference would be a script to allow users to enter data as they wish, but to clean after leaving the text field.

    Thanks in advance!

    Yes, there are a few changes during the passage of the code of the event in the sequence of keys to the Validate event.

    First of all, you need not try the willCommit. In fact, when the sequence of events of field reached the Validate event, the field is already committed. The Validate event does not therefore the property of willCommit.

    Secondly, in the Validate event, you work on the event.value and either event.change. Thus, you will replace accordingly.

    And who should actually do.

    I hope this can help.

    Max Wyss.

  • Remove the spaces and characters not a calculated field standard

    Hello

    I am fairy new forms Adobe script, but I managed to do that day. I am currently working on a form that we send to the suppliers to implement in our systems.

    One of the fields is called "Name of organization", which has a custom format script that modifies the text entered in uppercase in the field output:

    Event.Value = event.value.toUpperCase ();

    I have a hidden field "Own name branch" which is a code of calculation organistion which allows us to identify the organization within our systems (which can use letters). I need 'Own organization name' to be a calculation of "Name of organization" with all the spaces and non-standard characters deleted (", ([]) @$' &... etc").

    Could someone help me with this?

    Thanks in advance

    Chris

    This should do the trick:

    Event.Value = this.getField ("Organization Name").valueAsString.replace(/[\W,_]/g,"" ");

  • How can I program a button to retrieve an image from a user base and insert them into a form field?

    I need help (I have not the slightest idea) with a java script to program a button to retrieve an image from a user base and insert into a form field. To go to the menu select icon.

    [edited by moderator - he had no body to the post office and it was while heading a long title.] [Shorten the title and pasted the original title, plenty of length as the message body]

    Okay, that's actually quite easily. As the l' evenement event MouseUp button, select "Execute JavaScript" and enter this code:

    event.target.buttonImportIcon ();

    When you click the button it will open a file selection dialog and the selected file is displayed under the icon of the button.

  • Printing problems "only form fields.

    I have added text to a document and have selected "Only form fields" for printing, but the form fields do not appear. The fields appear when I print the entire document. I use XI Standard, and I printed before form fields. Any suggestions?

    I found the problem... I had added text through "Edit text and Images", when I went to add a comment text, I could print the "form fields only.

  • Form field ToolTip &amp; Read Out Loud

    I know that having ToolTips for form fields in a document PDF is a requirement for accessibility. When I use the view > read this Page in Acrobat Reader format does not read the ToolTips for the fields of the form, even if I turned on read form fields in Preferences > reading. I have a two checkboxes and text on the form fields.

    • What should I do to have the functionality of reading this Page to read the ToolTips for form field?
    • And, if the features of read this Page actually read the ToolTips form field, wouldn't not rather redundant that it reads the balloon and then, it also reads label printed text on the form?
    • Some types of fields in form, considered as ' not accessible?

    Thanks for any help you can provide.

    All types of fields in a standard (i.e. not XFA) PDF form are accessible if - and only if - properly tag.

  • Production of form fields/tabs via Acrobat?

    So I run a business where it would be extremely handy for my customers to click the tabs and fill them through the contracts that I give them. My question is, if I make form fields in a PDF via Adobe Acrobat document, my client will always be able to fill them through Adobe reader? Or do need to have acrobat click and fill in the form fields?

    You can fill the fields of the form with Adobe Reader.

  • I created a form using Acrobat DC and has not seen how constrain text input. For example, I want only the alpha characters in my name field, will not accept dates after 1930, ect. Where is this feature in the drafting of forms to create?

    How to create a text field to create a form to fill out from MS Word, who is obliged by using Acrobat DC form design? For example allow alphabetic characters only in this area. Or allow only the dates after 1920?

    Hi michaelg31489520,

    You can set properties for form field in Acrobat DC also PDF, Adobe Acrobat form field properties.

    If you want to implement all the constraints you can also use JavaScript.

    Kind regards
    Nicos

  • editing custom and calculations of form fields?

    On my excel spreadsheet report I follow the progress of the construction in linear feet of number from one station to the other.   Numbers station expressed exactly as with decimal places except the decimal point is replaced by the sign ' + '.  So if we type inOn my excellent spreadsheet report I follow the progress of the construction in linear feet of number from one station to the other.   Numbers station expressed exactly as with decimal places except the decimal point is replaced by the sign ' + '.  So, if we're typing in 200, it becomes 2 + 00 (which means station # 200... either 200 feet from the starting point of 0 + 00) it's really easy game this place in excel through shaped custom and isn't able to subtract effect station # else automatically calculates the daily footages.   How can I go to learn how to implement in the acrobat form fields?  Thank you

    OK, you can use the following script to custom size for a text field:

    Custom Format script for the text field

    If {(event.value)

    (Event.Value = util.printf("%.2f", event.value / 100) .replace (".", "+");

    }

    This can be expressed in plain language with: If the field is not empty, divide the value by 100, round off the result to the tenth closest and replace the comma with a sign more.

    A script format is used to change what is displayed in the field the value of the underlying field leaving unaltered, so the value of the field can be used in normal numeric calculations.

  • Create Acrobat with JavaScript form field and restrict numeric values only

    Hello

    I use a JavaScript loop to create a number of similar form fields. I'm trying to restrict the data entered in these fields of numbers only. I am able to validate the figures who are registered, but the fields still accept text, I don't want to. How can I make sure that text is not accepted?

    Script:

    var x 1 = 53;
    var y1 = 358;
    var x 2 = 123;
    var y2 = 340;

    for (var i = 1; i < 18; i ++) {}
    var name = "MyField" + i;
    var type = "text";
    var page = 1;
    rental var = [x 1, y1, x 2, y2];
    myField var = this.addField (name, type, page, location);
    myField.textSize = 10;
    myField.setAction ("Post", "AFRange_Validate (true, 0, true, 100) '");
    myField;
    Y1-= 18;
    Y2-= 18;
    };

    For example, if you want to display 2 digits to the right of the decimal separator with a comma of any currency symbol, thousands separator, you need to add:

    myField.setAction ('Format', ' AFNumber_Format (2, 0, 0, 0,-"\", false); ");

    myField.setAction ('Touch', ' AFNumber_Keystroke (2, 0, 0, 0,-"\", false); ");

  • JavaScript to adjust the font size for the form field number of characters?

    I have a form field that asks you 'full name' (first of all, middle, modified). Big, it is displayed in the upper part of the form. Some names are short and long.

    Is there a way of javascript to adjust the font size used in a form field based on the number of characters entered in the field?

    that is, if the name entered is Joe Smith, the font size is 30pt, if it's Alexander Hamilton font size is 20pt?

    Thank you!

    In general, I agree, but the Acrobat help section contains a lot of information. This specific bit of information you will find in this page: https://helpx.adobe.com/acrobat/using/pdf-form-field-properties.html#pdf_form_field_proper links

  • Form fields, menu and model Web links

    The site Im working with uses a pages administration panel, and from there the designer has added a page of form field in download for audio files and other pages where I can change the information which enter into force on the main site with other forms. When I tried to copy and paste the registration page to download audio files in the control panel of the main site for access to the public directory and then refreshed the browser that the page has not responded, I want it to work on the main site as a standard page for users, I even inserted a link to this page on the main site, not the admin of the site. error code 404 came.

    What does this part of the code? If it is not connected to the main site?

    < name of the form = 'album' method = "post" action = "<?" PHP echo site_url()?; ' > album/action_album "onsubmit =" return validate(); "enctype =" multipart/form-data">

    How is it not found on the main site? What php syntax is the problem. Or is it one of the other part of the site files? What should I do to convert the page to one of the pages of the site, even if it eas times admin page using the codeigniter framework?

    site_url() is a function, probably within CodeIgniter.

    I believe that the function requires an argument like site_url("album/action_album")

  • Why does not the meter of the quality of one of my choices of master password, regardless how I mix letters, numbers and non-alphanumeriques characters?

    I tried to create a master password, but it couldn't be done because the quality meter never accepted none of my passwords, even if I used a mixture of very complicated letters, numbers and special characters as well.

    There is no requirement when setting master password in Firefox. The password quality indicator is purely informative.

    If you try to fill the bar all the way, that's unlikely, unless you create a long password, or a mixture very complex of special characters, upper and lower case letters and numbers. Don't forget the password should be easy to remember and typed in, time after time. A highly secure password that is easily misspelled or forgotten is of no use.

Maybe you are looking for

  • Can I restore my favorites if they were saved to the same profile on another computer?

    Then my mother one of our computers restored without telling me or backup of one of my favorites. If I signed in the same profile of Mozilla on my computer that I've been on one that was wiped out, my favorites are in the places.sqlite file? If they

  • C1800 dosen't black printing.

    My black color printing dosen't C1800. I bought a new cartridge and it still doesn't work.

  • Call from Windows? Is - is this legitimate?

    I just got a call from someone who claims to be from windows. I have a Mac. They claimed that they had seen a malicious code on my computer and I had to go on my computer to check the code. I said I phone support Mac or Microsoft and confirm that it

  • Whenever I press the windows mail L button starts!

    OK here goes, I've been using vista for a while with no problems, all of a sudden every time I've reached the l (L) mail button windows starts and jumps in front of all im do, I play games online and use other things online and find it very frustrati

  • KB3145739 is not download site of Microsoft

    I am trying to download the above file.  My Windows Update has not been downloaded updates from 13/10/2015.  I searched online and see that others have managed to install the above update.  However, I tried to download the file several times and get