Validate Fields problem when fields are not visible or not loaded

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ismailc
    New Member
    • Sep 2006
    • 200

    Validate Fields problem when fields are not visible or not loaded

    I have an issue with in an xslt file which loads an aspx page.

    The below works fine when the fields are available & visible.

    Though, when the fields are not loaded or not visible then the script does not works. I get the following error:

    err: object required

    Code:
    function Test()
    {
      VE1020User=document.getElementById('VE1020User').value;
      VE1060NewSupplier=document.getElementById('VE1060NewSupplier').value;
    
     if(VE1020User=="")
     {
     }
     else if(VE1060NewSupplier=="")
     {		
     }					
     else
     {
    	document.getElementById('VE10999Done').click();
    	document.getElementById('___Submit').click();
     }
    
    }
  • ismailc
    New Member
    • Sep 2006
    • 200

    #2
    Hi, it seems to like the below but that is very messy as i have long complex if statements

    Code:
      VE1020User=document.getElementById('VE1020User').value;
      if(VE1020User=="")
     {
          showDialog('Warning','All Information is required (User).','warning');  
     }
    [B] else if(document.getElementById('VE1060NewSupplier').value=="")[/B]
     {

    Comment

    • ismailc
      New Member
      • Sep 2006
      • 200

      #3
      Please Help, not winning :(

      Comment

      • larztheloser
        New Member
        • Jan 2010
        • 86

        #4
        You could check to see whether the fields are loaded using the typeof command - if typeof document.getEle mentById('VE106 0NewSupplier') == "undefined" or something?

        Comment

        • ismailc
          New Member
          • Sep 2006
          • 200

          #5
          Thank You - i will give it a try :)

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            You could check to see whether the fields are loaded using the typeof command - if typeof document.getEle mentById('VE106 0NewSupplier') == "undefined" or something?
            you don’t need typeof for that test, just check for undefined.
            Code:
            if (document.getElementById('VE1060NewSupplier') === undefined)

            Comment

            • ismailc
              New Member
              • Sep 2006
              • 200

              #7
              Thank You this works great :)

              Comment

              Working...