Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:08:45+00:00 2026-06-02T16:08:45+00:00

When I click Submit, I get an error that the value is undefined in

  • 0

When I click Submit, I get an error that the value is undefined in my javascript that I use to validate my form for the aForm.propertyid.

I’m thinking this is related to using a select and trying to verify a value was chosen, as I’ve not validated against a select before and my other forms all work fine.

The correct values are in the $_POST in lease_edita, but the checkForm(this) doesn’t seem to pass anything to the javascript for validation – my checkForm(aValue) didn’t get aValue.

I added an alert in my checkForm to display the value for error checking, and it’s not getting a value. The onchange=”checkProperty(this.value);” works correctly though and does get a value.

propertyid is undefined @/lease_jsLibrary.js

I’m hoping I’m posting enough code… I’ve been working on this for 2 days without finding a fix, and am hopeful for suggestions or ideas.

The form:

<form name ="addEditLeaseForm" id="addEditLeaseForm" action="lease_edita.php" method="post" onsubmit="return checkForm(this)">
<?php
$output = <<<HTML
    <table class="center1" width="500">
        <tr>
            <td style="text-align: right; ">
            Property:
            </td>
            <td>
            <select name="propertyid" id="propertyid" stle="width:270px;" onchange="checkProperty(this.value);" />
                <option value='' selected></option>
HTML;
                $propList = getPropertyList();  // get the properties to populate the list box
                foreach ($propList as $aProperty) {
                extract($aProperty);
                $output .= <<<HTML
                <option value="$idproperty"
HTML;
                if ($idproperty == $prop_id) {
                $output .= <<<HTML
 selected
HTML;
            }
                $output .= <<<HTML
>$address</option>
HTML;
            }
                $output .= <<< HTML
            </select>
            <font id="propertyErr" style="visibility: hidden; color:red; font-weight: bold;">*Required</font>

            </td>
        </tr>
HTML;
    echo $output;
?>
    <tr>
    <td colspan ="2" align="center">
         <input type="submit" value="<?php echo $buttontext ?>" />
        <input type="button" name="Cancel" value="Cancel" onClick="history.go(-1);return true;" />
        </td>
    </tr>

    </table>
</form>

<p style="text-align: center">
    <input type="button" name="Property" value="Back to Property" onclick="window.location = '../property/property_main.php' " />
</p>

lease_jsLibrary.js contents:

function trim(strToTrim) {
    "use strict";
    //create a regular expression literal to identify leading and trailing spaces
    var reg = /^\s+|\s+$/g;
    //use the string method - replace - to remove leading and trailing spaces
    return strToTrim.replace(reg,"");
}

// checks whether an input control is empty (i.e., the user failed to enter a required input)
// note: it uses the trim method (see above) to eliminate white spaces before checking the input
function isEmpty(aControl) {
    return (trim(aControl.value).length == 0) ? true : false;
}

// checks for invalid characters in a string
function hasInvalidChars(aControl) {
    //create a regular expression literal to identify invalid characters
    var reg = /[^a-zA-Z0-9\s\&\!\?\.',_-]/;
    //use the regular expression method - test - to check whether the string contains invalid characters
    return reg.test(trim(aControl.value));
}

// removes starting and trailing white spaces
function trimBlur(strToTrim) {
    "use strict";
    //create a regular expression literal to identify leading and trailing spaces
    var reg = /^\s+|\s+$/g;
    //use the string method - replace - to remove leading and trailing spaces
    return strToTrim.replace(reg, "");
}

// checks whether an input control is empty (i.e., the user failed to enter a required input)
// note: it uses the trim method (see above) to eliminate white spaces before checking the input
function isEmptyBlur(aControl) {
    "use strict";
    return (trimBlur(aControl).length === 0) ? true : false;
}

function checkProperty(aValue) {
    "use strict";
alert(aValue);
    if (isEmptyBlur(aValue)) {
    document.getElementById("propertyErr").style.visibility='visible';
    document.getElementById("propertyid").style.borderColor='#FF3300';
    document.getElementById("propertyErr").innerHTML="*Required";
    return false;
    } else {
    document.getElementById("propertyErr").style.visibility='hidden';
    document.getElementById("propertyid").style.borderColor='';
    return true;
    }
}

function checkForm(aValue) {
    alert (aValue.propertyid);
    if (isEmpty(aValue.propertyid)) {
    document.getElementById("propertyErr").style.visibility='visible';
    document.getElementById("propertyid").style.borderColor='#FF3300';
    document.getElementById("propertyErr").innerHTML="*Required";
    return false;
    } else return true;
}

thanks in advance for tips, suggestions, and ideas..

this is fixed by changing to use:
if (isEmpty(aValue.propertyid.value))
thank you!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:08:46+00:00Added an answer on June 2, 2026 at 4:08 pm

    you want to check the <select> tag named “propertyid” ?

    function checkForm(aForm) {
        if ( !aForm.propertyid.value  ) { // so replace the line with this
            document.getElementById("propertyErr").style.visibility='visible';
            document.getElementById("propertyid").style.borderColor='#FF3300';
            document.getElementById("propertyErr").innerHTML="*Required";
            return false;
        } else {
            console.log( "submited" );
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there ASP button that won't submit post form data. Whenever I click an
This is a little form that I have that is a submit button a
I have a submit button when i click on that button i am having
I have a form which I want to submit upon button click which is
What I am trying to do is: When you click on a form submit
I have a form submit, where it get the values from the form and
I am trying to get a HTML/PHP form to submit properly. Some details: base
I'm having a form that is created dynamically depending on the value selected, it
i get this error, and i don't know how can be solved. I read
I have created a HTML5 Form and now on the click of the submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.