www.webdeveloper.com
Results 1 to 2 of 2

Thread: Strange Validation ISSUE

Hybrid View

  1. #1
    Join Date
    May 2013
    Posts
    2

    Strange Validation ISSUE

    Hi,

    I have on my local machines IE10; at the client location they are running IE10 and we both have the exact same version all updated.

    On my machines here I can run the pages without any errors and the validation works no problems.

    Same Browser and OS on the client machines is giving JavaScript errors and the code won’t work.

    Strongly enough the line “form.Addr1.value.length” passes no problems; but if fails at “else if (form.City.length < 1) {” with an error of “Error: Unable to get property 'length' of undefined or null reference”

    REMEMBER THIS ERROR IS NOT HAPPENING ON MY MACHINES, only on the client machines; all of them.

    <JavaScript Code>

    <script type="text/javascript">

    // Mike Belcher - mbdev@outlook.com - Post to the SendCustomerLetter.aspx page

    function SubmitSendCustomerLetter() {

    // GET THE VALUES WE NEED AND DO VALIDATION

    var form = document.getElementById("OOStitleForm");

    if (form.Addr1.value.length < 1) {

    alert("Please Enter an Address")

    form.Addr1.focus()

    return false

    }

    else if (form.City.length < 1) {

    alert("Please Enter a City")

    form.City.focus()

    return false

    }

    else if (form.CorrespTitleState.length < 1) {

    alert("Please Select a State")

    form.CorrespTitleState.focus()

    return false

    }

    else if (form.Zip.length < 1) {

    alert("Please Enter a Zipcode")

    form.Zip.focus()

    return false

    }

    else {

    //alert("Validation Has Passed; lets run the code")

    // Here we do the post

    form.action = 'SendCustomerLetter.aspx';

    form.target = 'SendCustomerLetterCorrespondence';

    form.submit();

    //return true

    }

    }

    </script>
    </JavaScript Code>

    <html>

    <table border='0' cellpadding='2' width='100%' id='CorrespondanceMenu'>

    <tr>

    <td width='150' align='right'>Customer Addr 1 </td>

    <td width='346'><input name='Addr1' type='text' id='Addr1' value='12345 The Matrix' style='color:#0066FF;width:254;height:22' size='50' /></td>

    <td width='368'>

    <div align='left'>

    <table border='0' cellpadding='0' width='100%' cellspacing='0'>

    <tr>

    <td width='50'>Phone</td>

    <td width='159'><input name='Phone1' type='text' id='Phone1' value='410-123-4321' style='color:#0066FF;width:140;height:22' size='25' /></td>

    <td width='29'>

    <input type='button' name='PhoneCall' id='PhoneCall' value='Phone Call' onClick="SubmitPhoneSimple();">

    <input type='hidden' name='TitleID' value='1946'/></form>

    </tr></table>

    </div>

    </td>

    </tr>

    <tr>

    <td width='150' align='right'>Customer Addr 2 </td>

    <td width='346'><input name='Addr2' type='text' id='Addr2' value='HBO and other movie channels' style='color:#0066FF;width:254;height:22' size='50' /></td>

    <td width='29'>

    <input type='button' name='SendCustomerLetter' id='SendCustomerLetter' value='Send Customer Letter' onClick="SubmitSendCustomerLetter();">

    </tr>

    <tr>

    <td width='116' align='right'>City </td>

    <td colspan='2'>

    <div align='left'>

    <table border='0' cellpadding='0' width='84%' cellspacing='0'>

    <tr>

    <td width='152'><input name='City' type='text' id='City' value='Matrixville' style='color:#0066FF;width:140;height:22' size='30' /></td>

    <td width='38'> State </td>

    <td width='68'>

    <select name='CorrespTitleState' id='CorrespTitleState' style='color:#0066FF;'>

    <option value='FL' selected>FL</option>

    <option value='AK'>AK</option>

    <option value='AL'>AL</option>

    <option value='AR'>AR</option>

    <option value='AZ'>AZ</option>

    <option value='CA'>CA</option>

    <option value='CO'>CO</option>

    <option value='CT'>CT</option>

    <option value='DE'>DE</option>

    <option value='FL'>FL</option>

    <option value='GA'>GA</option>

    <option value='HI'>HI</option>

    <option value='IA'>IA</option>

    <option value='ID'>ID</option>

    <option value='IL'>IL</option>

    <option value='IN'>IN</option>

    <option value='KS'>KS</option>

    <option value='KY'>KY</option>

    <option value='LA'>LA</option>

    <option value='MA'>MA</option>

    <option value='MD'>MD</option>

    <option value='ME'>ME</option>

    <option value='MI'>MI</option>

    <option value='MN'>MN</option>

    <option value='MO'>MO</option>

    <option value='MS'>MS</option>

    <option value='MT'>MT</option>

    <option value='NC'>NC</option>

    <option value='ND'>ND</option>

    <option value='NE'>NE</option>

    <option value='NH'>NH</option>

    <option value='NJ'>NJ</option>

    <option value='NM'>NM</option>

    <option value='NV'>NV</option>

    <option value='NY'>NY</option>

    <option value='OH'>OH</option>

    <option value='OK'>OK</option>

    <option value='OR'>OR</option>

    <option value='PA'>PA</option>

    <option value='RI'>RI</option>

    <option value='SC'>SC</option>

    <option value='SD'>SD</option>

    <option value='TN'>TN</option>

    <option value='TX'>TX</option>

    <option value='UT'>UT</option>

    <option value='VA'>VA</option>

    <option value='VT'>VT</option>

    <option value='WA'>WA</option>

    <option value='WI'>WI</option>

    <option value='WV'>WV</option>

    <option value='WY'>WY</option>

    </select></td>

    <td width='32' align='right'>Zip </td>

    <td width='148'><input name='Zip' type='text' id='Zip' value='21229' style='color:#0066FF;width:140;height:22' size='10' /></td>

    <td> </td>

    </tr>

    </table>

    </div>

    </td>

    </tr>

    </table>

    </html>

    Makes no sense why the same browser on two different systems, one has errors and the other has none.

    Any Ideas?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    in this code there is no any element having id 'OOStitleForm'. as i understand this code must not work at all. the other thing i can't understand is why you are trying to get form.City.length instead of form.City.value.length...

    p.s. please, read my signature

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles