Form Field Validation

Hi All,
I am new to PDF forms so sorry if this is a dumb question. I have a number field which I need it to validate the number of digits it must =13 or be blank.
Is there a simple way to do this? I have set the field max size to 13 digits but I need to stop them inputting less than 13 digits it must match 13 exactly.
Any help would be great.
Many Thanks
Adam

You can use the following code as the custom Validate script for the field:
// Custom Validate script
if (event.value && event.value.length !== 13) {
    // Let the user know something is wrong
    app.alert("Please enter a total of 13 digits.", 3);
    // Optionally, reject the value if only 1-12 characters
    event.rc = false;
That last line of code will reject the entry if there are from one to twelve characters. Just leave it out if that's not what you want to do.

Similar Messages

  • PDF form field validation - 2 criterias?

    Does anyone know how can I get a numerical pdf form field to validate within a range as well as validate that the value is equal to or less than the value of another numerical field?
    Thanks!

    I think the following custom Validate script will do what you want:
    function range_validate1() {
        // Do nothing if field is blank
        if (!event.value) {
            return;
        // Initialize some variables
        var sError = "";
        var nMin = 0;
        var nMax2 = 2e6;
        var nVal = +event.value;  // Value user entered, converted to a number
        // Get the other field value, converted to a number
        var nMax1 = +getField("Text1").value;
        // If the value is less than the minimum
        if (nVal < nMin) {
            sError = "Please enter a value greater than or equal to: " + nMin;
        // If value exceeds the other field value...
        if (nVal > nMax1) {
            sError = "Please enter a value less than or equal to: " + nMax1;
        // If value exceeds the max. possible value   
        if (nVal > nMax2) {
            sError = "Please enter a value less than or equal to: " + nMax2;
        // Alert the user and reject the value
        if (sError) {
            app.alert(sError, 0);
            event.rc = false;
    // Call the function
    range_validate1();
    The function can be placed in a document-level JavaScript, but the last line should be the custom Validate script for the field. Replace "Text1" in the line containing the getField statement to the actual name of the other field.

  • Form field validation: All required data lost when clicking browser-back-button!

    Hi folks,
    I have a big problem using the validation text  field components of Spry when the user must click the browser back button (or clicking a history.back()-Link) because he has  entered a wrong CAPTCHA-code!
    Right now, all the data - only in the required fields - not in the optional  fields!!! - is lost and the user has to enter all data once  again;-(
    Does anybody know why only the data in the  required fields is lost? Is there a nice workaround?
    I really  appreciate a quick answer:-)
    Kind regards from cloudy Germany
    Thomas

    rememberFormInputs('frmlogin', 'input-');
    'frmlogin' should be the id of page, not the name. so on your <form> tag, add the id="frmlogin"
    remove the
    // overload alert
    function alert(str) {
         var el = document.getElementById('alert');
         if (el) {
              el.value += str+"\r\n";
    Its really bad practice to overwrite the alert. and inside the rememberFormInputs remove these lines:
    alert('old value remembered: '+old_value);
    alert('setCookie: '+name + ' = '+value);
    and it should work

  • Multiple Form Field Validation

    I run throught these series of checks before submitting the variables to the .jsp script. Problem is that it will ignore the sender name and receipient name as long as there are two email addresses. Why is that?
    if (sendername eq "") {
            nameerrorTXT.text = "PLEASE ENTER YOUR NAME";
        if (emailfrom.indexOf("@")<0 or emailfrom.indexOf(".")<0) {
            emailfromerror.text= "PLEASE USE A VALID EMAIL ADDRESS";
            emailfromTXT.text = "";
        if (recipientname eq "") {
            recipientnameerrorTXT.text= "PLEASE ENTER YOUR FRIEND'S NAME";
            recipientnameTXT.text = "";
        if (emailto.indexOf("@")<0 or emailto.indexOf(".")<0) {
                emailtoerror.text= "PLEASE USE A VALID EMAIL ADDRESS";
                emailtoTXT.text = "";
        } else {
            _root.sendername = sendername;
            _root.recipientname = recipientname;
            _root.emailfrom = emailfrom;
            _root.emailto = emailto;
            _root.emailsubject = sendername + " " + emailsubject;
            _root.emailbody = emailbody;
            _root.loadVariables("/jsp/sendMail.jsp", "POST");
            sendernameTXT.text = "";
            recipientnameTXT.text = "";
            emailfromTXT.text = "";
            emailtoTXT.text = "";
            nextFrame();

    Thanks Klad,
    I actually tried that route. The problem was that if any one of those 'if' statements were true the the function would stop and I needed the function to check AND respond to each field if needed. I found that the 'else' statement would fire regardless to all the 'if' statements except for the one just before it.
    I'm sure there is a better way to do and I'd like to know how but I solved the issue by creating a last 'if' statement that lumped all the if statements together. This way I would achieve the error feedback needed AND keep the 'ELSE' statement from firing. See below
    submitBNT.onPress = function(){
        if (sendername eq undefined | sendername eq "") {
            nameerrorTXT.text = "PLEASE ENTER YOUR NAME";
            sendernameTXT.text = "";
        if (emailfrom.indexOf("@")<0 | emailfrom.indexOf(".")<0) {
            emailfromerror.text= "PLEASE USE A VALID EMAIL ADDRESS";
            emailfromTXT.text = "";
        if (recipientname eq undefined | recipientname eq "") {
            recipientnameerrorTXT.text= "PLEASE ENTER YOUR FRIEND'S NAME";
            recipientnameTXT.text = "";
        if (emailto.indexOf("@")<0 | emailto.indexOf(".")<0) {
                emailtoerror.text= "PLEASE USE A VALID EMAIL ADDRESS";
                emailtoTXT.text = "";
        if (sendername eq undefined | sendername eq "" | emailfrom.indexOf("@")<0 or emailfrom.indexOf(".")<0 | recipientname eq undefined | recipientname eq "" | emailto.indexOf("@")<0 or emailto.indexOf(".")<0) {
            /// DO NOTHING
        } else {
            processMailForm();

  • 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.

  • 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

  • Validating and highlighting a form fields.

    Hi all!
    I have a form, with a lot of fields, which must be NOT blank. And they must NOT be highlighted.
    So, on the one hand: i have to make these fields required, for don't let users print the form with blank fields. But if I’ll do it with standard settings, the fields will be highlighted with a red color (default settings of the acrobat reader). Yes, these settings can be changed in Acrobat Reader, but as the form will be used by a lot of users - i can't force them all change their settings.
    On the other hand: If the form fields are set to be optional, then validation scripts don't work on empty fields.
    So, is there any ways to solve this problem?

    Well, then not only red borders disapper, but also the blue highlight of fields background, so, users can't see where to type text. And that is bad(
    So, the only way i can see - is to turn off highlight (app.runtimeHighlight = false;), and also, chance fields fillColor, like that:
    enter: this.fillColor = "255,255,255";
    initialize: this.fillColor = "204,215,255";
    exit: this.fillColor = "204,215,255";
    prePrint: this.fillColor = "255,255,255";
    But this way there will be a lot of "monkeyjob" to change color setting of every field...

  • Automatically displaying the error text for a form field when the validator fails?

    Hi,
    Flex 2 has a very nice feature to display custom text next to
    a form field whose validation failed. But the user has to move the
    mouse over the form field to display the text. Is there a way to
    invoke this feature programmatically?
    What I would like to do is validate form fields on submit and
    - if validation fails for a form field - set focus on that form
    field and automatically display the custom error text in the red
    blurb. Focusing works fine but I cant' get the text to render...
    Markus

    Thanks Bregent.
    Weirdest thing...I just tried a Google search for a solution to this problem and came across another thread on this forum.  By the time I got to the bottom of it I realised one of those taking part was myself from years ago!  Jeesh, been here before or what!
    Changed my recordset to...
    <%
    Dim rsPROP__MMColParam
    rsPROP__MMColParam = "0"
    If (Request.Form("categoryID") <> "") Then
      rsPROP__MMColParam = Request.Form("categoryID")
    End If
    %>
    <%
    Dim rsPROP__MMColParam1
    rsPROP__MMColParam1 = "1"
    If (Request.Form("categoryID") <> "") Then
      rsPROP__MMColParam1 = Request.Form("categoryID")
    End If
    %>
    <%
    Dim rsPROP
    Dim rsPROP_cmd
    Dim rsPROP_numRows
    Set rsPROP_cmd = Server.CreateObject ("ADODB.Command")
    rsPROP_cmd.ActiveConnection = MM_cs_STRING
    rsPROP_cmd.CommandText = "SELECT prodid, product, categoryID FROM dbo.products WHERE ISNULL(?,0) = 0 OR categoryID = ?"
    rsPROP_cmd.Prepared = true
    rsPROP_cmd.Parameters.Append rsPROP_cmd.CreateParameter("param1", 5, 1, -1, rsPROP__MMColParam) ' adDouble
    rsPROP_cmd.Parameters.Append rsPROP_cmd.CreateParameter("param2", 5, 1, -1, rsPROP__MMColParam) ' adDouble
    Set rsPROP = rsPROP_cmd.Execute
    rsPROP_numRows = 0
    %>
    ...and it works fine.
    Appreciate the help. I would have taken your advice and done an If Else on the WHERE clause to acheive the same.
    Thank you.
    NJ

  • How to revise form field value in query and skip validation

    Hi all,
    I have a 10g form that has a field which I want to manipulate during query. I want to display a different value depending upon its orignal value. I did this with a Post-Query trigger on the field's datablock. However, now, when I attempt a new query, the form thinks I've changed the field (which I did). I want to change the field but trick Forms into thinking there were no updates. How do I do this? Note: the field is a list item that has a style of combo box.
    Thanks, Mike

    Ammad,
    The reason is that sometimes the list returns the record group's key value (the second column) instead of the intended value (in the first column). This is because the record group is based on a SQL query. There are some values which are no longer in the table queried by the record group, thus the key value is displayed. I would rather nothing be displayed. As of now, I display a message indicating that there is a problem with the LOV.
    I know about using a non-database form field. But I don't have any room left and I don't want to lay the non-database field on top of the database field and then have to enable/disable the two fields.
    A friend at work suggested setting update_permission to trick Forms. Tried it but not successful yet.
    Thanks, Mike

  • Acrobat form fields- is it possible to have a sign-in validation before proceeding?

    I am building an interactive pdf for one of my clients. She would like for me to create a registration form on page 1, which would be a mandatory sign-in delivered to an online data base.
    Here is my question: Is it possible to create a pdf registration form that only allows access to the rest of the pdf once they have completed the form?
    Any information is much appreciated!
    Wendy

    There are various ways this can be done, but none of them will work 100% of the time.
    For example, you could:
    - Hide all the form fields until the user fills in the data on the first page
    - Use a script to prevent the user from leaving the first page until the form is filled
    - Place the rest of the file in an attached PDF which will be opened when the user fills the form

  • Set maximum size in Text Form Field Options for a field in bi publisher RTF

    Hi All,
    How to set maximum size in Text Form Field Options for a field in bi publisher RTF.
    I have a RTF whch is having a field in that i need to add some validation condition but after adding certain condition in Add help text tab ,it is not accepting after certain length, how i can increase the length to unlimited,please help me on this
    Thnaks

    Form fields have some restrictions if your are using version lower than 11g.
    They can accommodate only 393 chars. You can add the text in both status bar and help key, which can in total consume 393 chars.
    If your code logic is more than that, it can be split into multiple form fields as Avinash suggested or you can use sub template logic and handle coding over there. Again in sub template code can be within/outside form fields.
    So there is no option for user to increase the size of form field.

  • Mandatory field validation on Page links.

    We have created a Portal application where we included different applications as taskflows. We have also created a tabbed interface which helps us to communicate from one task flow to another taskflow. When we are in one page of taskflow and try to move to another page of different taskflow using tabbed interface we receive mandatory field validation error which prevents us to move to any other page until we fill all the mandatory fields. We need to move to different page of taskflow by using the tabbed interface even without filling all the necessary mandatory fields. Can anyone help us to resolve this issue as this is very important for our project.

    <b>Layout</b>
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="Check Pernr " >
        <htmlb:form>
          <htmlb:textView text   = "Personnel No."
                          design = "EMPHASIZED" />
          <htmlb:inputField id    = "pernr"
                            value = "<%= lv_pernr %>" />
    <%
    if lv_no_pernr = 'X'.
    %>
    <script language="Javascript">
    alert ("Personnel no. is not Valid")
    </script>
    <%endif.%>
       </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    <b>ONINPUTPROCESSING</b>
    DATA: l_pernr TYPE persno.
      DATA: data TYPE REF TO cl_htmlb_inputfield.
      data ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                             name     = 'inputField'
                                             id       = 'pernr' ).
      IF data IS NOT INITIAL.
        l_pernr = data->value.
      ENDIF.
    CLEAR lv_no_pernr.
    SELECT SINGLE pernr FROM pa0000 INTO l_pernr WHERE pernr EQ lv_pernr.
    IF sy-subrc NE 0.
      lv_no_pernr = 'X'.
    ENDIF.
    <b>PAGE ATTRIBUTES</b>
    lv_no_pernr     TYPE     FLAG
    lv_pernr     TYPE     PERSNO
    hope this helps.
    A

  • How do I cause a form field to raise its blur event?

    I have a web form that displays an editable pdf document.  When a user clicks a button the form will get validated.  If one of the fields being validated has the focus its value will not get updated when I need to do the validation.  For example, if I am validating the First Name field and I type text in it and then click on a button (from the web) to cause validation, the document says the field is invalid because there is no data.  If I hit tab on the field to focus a new field the validation works fine.  How can I cause the field to get updated?  I have tried to create an empty form field and focus to that first but that does not work.

    Nope, I have a button on the website that the user clicks to send a validation request.

  • Preventing ADF Input Form from validating

    Can anyone say how can i prevent an ADF Creation Form from validating the inputText fields when there is no data entered in any of the fields and the user press a Cancel button to cancel the input and return/navigate to another page???
    Currently when i try that that the fields are validates and a message is displayed saying the field requires a value. And it will not allow me to navigate to another page unless some value is entered. Why is this so ?
    Thanks

    I figured this out myself, actually this was quite simple.- just set the 'immediate' property on the component (button) to 'true'.

  • Filling of form fields changing depending on how PDF is opened, why?

    First of all, here is the error message that I am trying to deal with:
    "This document contained certain rights to enable special features in Adobe Reader. The document has been changed since it was created and these rights are no longer valid. Please contact the author for the original version of this document."
    Software & PDF details:
    Adobe Reader 8. V8.1.1
    PDF Producer:     Toolkit http://activepdf.com
    PDF Version:       1.5 (Acrobat 6.x)
    The PDF is set to with:
    Filling of form fields: Allowed
    After investigation I have found that:
    If I open the file by double clicking, I am able to fill in the fields and save without any problems.
    If the file is opened as a result of a software process trigger (which is what I actually want to achieve), the "Filling of form fields" is changed to "Not Allowed". This then results in the error message described above.
    Also, I have another PDF with exactly the same settings as above (PDF version and Producer etc), which successfully generates as a result of the software process trigger. This file that works does not change the "Filling of Form Fields" value.
    So, my question is, why would a particular PDF change the "filling of form fields" value depending on how it is opened?

    Ok, that is a useful result, telling us a lot.
    Some background you need. Reader 8 CANNOT SAVE FILLED IN FILES normally. To be able to save them they must be specially prepared. This is called "Reader enabling". (In your original message, "rights to enable special features in Adobe Reader") To prepare a file Acrobat can be used, or a server product which has had many names but is currently LiveCycle Reader Extensions. If this is not done, the form cannot be saved, whatever its origin.
    Now, a file may not be changed/damaged in even the slightest way after this preparation. This will produce the message seen.
    So, your test seems to show
    - the original file is OK, undamaged
    - by the time the file is delivered from the database to the user it has been damaged/changed.
    So, you now have a path to pursue through the software.
    (To clarify: this only applies if you used Windows Explorer to save the file, NOT any save function in Reader; if you saved in Reader please repeat the test with Windows Explorer).
    Message was edited by: Test Screen Name

Maybe you are looking for

  • Changes in vendor details

    Hi All, I need to report changes in employee vendor's personal details. That is, His name change (if any) address change bank information change where can i find these details Can anyone please suggest how can i do this? Thanks

  • Oxford FireWire Bridge Utilities

    This is a general external hardware question that didn't really fit in any particular listed category. If the moderators think it belongs somewhere else, feel free to move it appropriately. My problem is as follows: Due to an embarrassing faux pas -

  • Display records in JSP

    I am completely stuck at this point and need urgent help. here is what i have done till now: i have one jsp page called first.jsp which displays records in RowsetBrowser from View Object A. The attributes are ID,name,Location. in View Object A i have

  • Backup - how to restore the entire configuration (system cloning)

    Hi, is it possible to backup the entire system configuration on order to restore file and system configuration? Time machine is a file backup, if I reset yosemite I've to configure the entire operative system...

  • Itunes doesn't recognize iPhoto library - a short-term workaround

    I'm having the same problem everyone else is - iPhoto has a library full of stuff.  iPhoto 'sees' it, Keynote 'sees' it, Pages 'sees' it - iTunes doesn't!  I have found a quick workaround for those photos I really need to have on my ipad right now!