Validating Form Fields

Hi All,
I am using Flash 8;ActionScript 2.0.
I have a form with serveral input fields. I want to validate
these fields. For example make sure the email input is in the
correct format, that the telephone input has only numbers, etc.
All of the tutorials I have looked at attach the AS to the
submit button. I do not want to do this. What I'd like to set up is
have AS check the input field entry to make sure it's correct PRIOR
to the submission of the form.
Is this possible?
This is the AS for the form with no validation:
tl = this;
initF();
stop();
//Tabs
nameTF.tabIndex = 1
emailTF.tabIndex = 2
companyTF.tabIndex = 3
phoneTF.tabIndex = 4
messageTF.tabIndex = 5
//End Tabs
sendBtn.onRelease = function() {
if (checkFormF()) {
sendEmailF();
} else {
tl.gotoAndStop("errorFrame");
function checkFormF():Boolean {
if (nameTF.text == "Name" || companyTF.text == "Company" ||
emailTF.text == "E-mail" || phoneTF.text == "Phone" ||
messageTF.text == "Message" || nameTF.text == "" || companyTF.text
== "" || emailTF.text == "" || phoneTF.text == "" || messageTF.text
== "") {
return false;
} else {
return true;
function sendEmailF() {
sendLV = new LoadVars();
receiveLV = new LoadVars();
receiveLV.onLoad = function(s) {
if (s) {
tl.gotoAndStop("thankyouFrame");
sendLV.name1 = nameTF.text;
sendLV.email = emailTF.text;
sendLV.message1 = messageTF.text;
sendLV.phone = phoneTF.text;
sendLV.company = companyTF.text;
sendLV.sendAndLoad("mailer5.php",receiveLV,"POST");
function initF() {
nameTF.text = "Name";
companyTF.text = "Company";
emailTF.text = "E-mail";
phoneTF.text = "Phone";
messageTF.text = "Message";
label_01 = "Name";
label_02 = "Email";
label_03 = "Company";
label_04 = "Phone";
label_05 = "Message";
nameTF.text = label_01;
emailTF.text = label_02;
companyTF.text = label_03;
phoneTF.text = label_04;
messageTF.text = label_05;
this.onEnterFrame = function() {
nameTF.onSetFocus = function() {
if (nameTF.text == label_01) {
nameTF.text = "";
nameTF.onKillFocus = function() {
if (nameTF.text == "") {
nameTF.text = label_01;
emailTF.onSetFocus = function() {
if (emailTF.text == label_02) {
emailTF.text = "";
emailTF.onKillFocus = function() {
if (emailTF.text == "") {
emailTF.text = label_02;
companyTF.onSetFocus = function() {
if (companyTF.text == label_03) {
companyTF.text = "";
companyTF.onKillFocus = function() {
if (companyTF.text == "") {
companyTF.text = label_03;
phoneTF.onSetFocus = function() {
if (phoneTF.text == label_04) {
phoneTF.text = "";
phoneTF.onKillFocus = function() {
if (phoneTF.text == "") {
phoneTF.text = label_04;
messageTF.onSetFocus = function() {
if (messageTF.text == label_05) {
messageTF.text = "";
messageTF.onKillFocus = function() {
if (messageTF.text == "") {
messageTF.text = label_05;
Your help is much appreciated,
Scott

I don't have a solution for you. The reason that the existing
solutions that you've found use the submit event is quite simple.
It's the least intrusive place to check for errors. You have a
limited number of events where you can place this content checking
code. If you wanted to test the email address that the user entered
after that entry was made, how would you do that? You can tell when
the user gives focus to the textfield, you can tell when the user
enters a character, you can tell when the textfield loses focus.
None of these events is really appropriate for testing the content.
What is the problem with waiting until the submit button is
used?

Similar Messages

  • 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

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

  • I have an email validation script on my page and a populate form fields script that doesn't work unless it's the only script written. Here are the scripts. Thanks

              <script type="text/javascript"><!--
    function validateForm() {
    with (document.drbrake) {
    var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";
    if (fullname.value == "") alertMsg += "\nfullname";
    if (emailcheck.value == "") alertMsg += "\nemailcheck";
    if (telephone.value == "") alertMsg += "\ntelephone";
    if (selectproduct.value == "") alertMsg += "\nselectproduct";
    if (problem.value == "") alertMsg += "\nproblem";
    if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n") { alert(alertMsg);
    return false;
    } else {
    return true;
    // -->
    </script>
            <script language="JavaScript1.2">
    //Advanced Email Check credit-
    //By JavaScript Kit (http://www.javascriptkit.com)
    //Over 200+ free scripts here!
    var testresults
    function checkemail(){
    var str=document.validation.emailcheck.value
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$ /i
    if (filter.test(str))
    testresults=true
    else{
    alert("Please input a valid email address!")
    testresults=false
    return (testresults)
            </script>
                                <script>
    function checkbae(){
    if (document.layers||document.getElementById||document.all)
    return checkemail()
    else
    return true
    </script>

    I do see issues with the script, but do you realize that HTML5 has all this capability build in, so not a single bit of the code you posted is needed? Of course there may be a reason you are doing it the way you are, but I don't know what that reason would be.
    In your forms, you can simply add "required" to an input field to make it required. And by making an email field the email type, it will automatically be validated for correctness. See below:
    <input type='text' value='<?php echo last_name ?>' name='last_name' required />
    <input type='email' value='<?php echo email ?>' name='email' required />
    Assuming that your form is processed by PHP, you would then use further validation in PHP. But the HTML5 validation is just as good as javascript validation and easier to use.
    With the HTML5 validation, all fields remain populated and the form cannot be submitted if anything fails validation.  I added the value attribute to the input examples because normally, if the PHP validation fails, you want to re-populate the form with what is stored in the POST array.

  • 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

  • Validation of a form field value against existing values in database tables - urgent.

    Hi,
    I have created a "form based on a table". Is there a way of validating the fields entered by checking that they are valid values existing on another table in the database? So if they are not valid values, the data would not be inserted and an error would be flagged to the user.
    I have not yet been able to find any questions on this forum which deal with this exactly.
    Thanks,
    Steve.

    On Insert button try following (change to your requirement),
    declare
    usr_id varchar2(100) := portal30.wwctx_api.get_user;
    usr_name varchar2(100);
    my_deptno number(10);
    begin
    my_deptno := p_session.get_value_as_NUMBER(
    p_block_name => 'DEFAULT',
    p_attribute_name => 'A_DEPTNO');
    usr_name := null;
    begin
    select ename
    into usr_name
    from emp
    where dept=my_deptno;
    exception
    when others then null;
    end;
    if usr_name is null
    then
    htp.p('<script> alert("Dept wrong"); </script>');
    else
    doInsert;
    end if;
    end;

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

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

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

  • Is it possible to create a editable pdf with validation(required field) using Adobe Acrobat pro version?

    Hi,
    the subject says it all. I have downloaded the trail version to see if its possible to create a editable pdf with validation(required field) using Adobe Acrobat pro version?
    Basically, I will have to create a pdf form where users fill it and send it back to me. there will be required fields (the textbox and check box) that user need to fill before saving the editable pdf?
    Is it possible. if so, can someone kind enough to point to me right directions?
    Thanks in advance.

    Thanks for reply. What I am trying to achieve is to give an option for the user to download the pdf form and once the user tries to save the pdf, it validates with the required field. I managed to create the editable pdf with required fields option. I just need that validation to be done when user click on save file. How can I achieve this? thanks so much for your help.

  • 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

  • PDF/A vs. Form Fields (checkboxes, radiobuttons)

    I've question regarding the PDF/A specification and would appreciate some clarification.
    The specs says:
    "If an annotation dictionary contains the AP key, the appearance dictionary that it defines as its value shall contain only the N key, whose value shall be a stream defining the appearance of the annotation. [...] Every form field shall have an appearance dictionary associated with the field's data. A conforming reader shall render the field according to the appearance dictionary without regard to the form data."
    Now i have a document which is fully PDF/A compliant however the acrobat preflight (8 & 9) check fails with the message that my checkboxes do not only contain the /N key. However they do contain just the /N (normal) appearances.
    1.) So what's the problem? (Can't think that this should be a bug since intarsys PDF/A validation also reports it...)
    The PDF Spec 1.4 defines the 'normal' appearance of a checkbox like that:
    /AP << /N << /On formXObject1 /Off formXObject2>>>>
    2.) Or does the spec mean, that there can only be one appearance inside the /N enty?
    Then PDF 1.4 states:
    "The appearance for the off state is optional, but if present must be stored in the appearance dictionary under the name Off."
    3.) So if i only define the "On" state the document will become fully PDF/A compliant?
    4.) And what about the Appearance state (AS)? PDF 1.4 states:
    "The choice between the checked and unchecked appearance states is determined by the AS entry in the annotation dictionary"
    But PDF/A does not mention the /AS key but it is vital for checkboxes...?! According to the spec a viewer has to "render the field according to the appearance dictionary" -> but checkboxes can have two states ....
    Thanks for bringing any light on this!
    /ToM

    Meaning like this:
    AP<< /N << stream [...] enstream>>>>
    So basically after filling out the pdf the viewer has to:
    1.) take the /AS key
    2.) get the proper appearance dictionary (on or off)
    3.) and write that value into the AP (and therefore overwriting the old 'On' and 'Off' dictionaries)
    to get a valid PDF/A document afterwards?
    /ToM

  • PDF Form Field calculates AVERAGE incorrectly

    I have a PDF Form field that is set to calculate the AVERAGE of 4 other fields. Each of those other fields has its validation set to allow only the values 1 through 3.
    The Average field is dividing the total by 4 even if a person only fills out 2 of the fields. I thought AVERAGE would only count the fields that have a value in them. But it's seeing the ones that are blank as containing a 0, even though that is an invalid value for that field.
    How can I fix this? The customer really wants the option of having up to 4 fields and wants an average of just the ones that are filled in. I thought that was what Average was supposed to do.
    Is there a way to tell Acrobat to ignore the fields if their value is less than 1?

    I responded to this question here: http://answers.acrobatusers.com/PDF-Form-Field-calculates-AVERAGE-incorrectly-q13211.aspx

Maybe you are looking for

  • Why is my .psd file not rendering correctly in ae

    Some layers of the .psd document are not rendered correctly. However they are imported. The strange thing is that when I first move from Photoshop to Illustrator, save it as an .ai file it is rendered properly (in Ae). I am kind of clueless as to wha

  • Best practice for OSB to OSB communication

    Cross posting this message: I am currently in a project where we have two OSB that have to communicate. The OSBs are located in different security zones ("internal" and "secure"). All communication on a network level must be initiated from the secure

  • Flaky Time Capsule Wireless Behavior

    Must say I am not impressed with the set-up and flaky behavior of the new TS. It seems to be working now, after fiddling with the flakyness for the past several nights, but can't help but wonder if what I experienced is normal, or if I might have an

  • How does safari open in full screen?

    When I open safari, the page doesn't open in full screen, so I have to scroll sideways the entire time. How do change the page settings, so that safari automatically opens in full screen? Help!

  • While listening to music in my car, I don't have the option to choose between bluetooth and headphones anymore. Why?

    On IOS 6 and earlyer, I use to be able to choose between the bluetooth or the headphone jack. Now, I can only play music true my bluetooth and I can't pause the music. Anybody has a solution?