locked
why infinite loop in this simple java script to check empty ? RRS feed

  • Question

  • Hi Friends,
    
    var d= getTagFromIdentifierAndTitle("Select","DropDownChoice","Completion Status"); 
     var CompModules = getTagFromIdentifierAndTitle("INPUT","TextField","Completed Modules"); 
    
     if (d.value=='Not Started' && CompModules!="")
            
           {
            alert('Please donot fill completed Modules,as Your Status is Not Started!');
              return false ;
    
           }
    
    return true;
    
    and respective column in list is simply choice and single line of text(Moss 2007)
    
    i am getting alert every time either i fill completed modules or not
    .........it should not be ..as my condition is seeming ryt
    
    Please help
    

     


    sudhanshu sharma
    Friday, September 9, 2011 1:14 PM

All replies

  • You condition is right but seems to code error change 

     

    CompModules!="" to CompModules.value !=""

     


    Rahul Sharma
    http://sharepointarrow.blogspot.com/
    Saturday, September 10, 2011 6:46 AM
  • Hi Rahul,

    I already tried with this CompModules.value !="" ,CompModules.value !=0,CompModules.value !=null  but after writing this i am getting error in all 3 combinations

    value is null or not an object..........so i tried with CompModules!="" but problem is this is working but running infinitely .....

    i want to clarify 1 thing -i also did a validation (server side).....by AS.Net validation control(regular expression).......if someone enter character then it shud not be accept..........

    and for client side .....i am writing this java script.........if training status== not started && completed modules !="" then alert....................


    sudhanshu sharma
    Monday, September 12, 2011 3:42 AM
  • See your function getTagFromIdentifierAndTitle

    returning the object of the control not its value. like for 'd'. So it always return true for your control. First check wether

    your control object is coming from your function or not. Then check the control object is same or returning other object.

    and try below condition

    if( CompModules !="undefined" to CompModules.value !="undefined"


    Rahul Sharma
    http://sharepointarrow.blogspot.com/
    Monday, September 12, 2011 5:26 AM
  • my script worked well but as i insert custom list form and do more validations by controls then i got 'value ' is null or not an object error. >

     


    sudhanshu sharma
    Monday, September 12, 2011 5:43 AM
  • Hi Rahul,

    May i know ur contact id if u dont mind(:



    sudhanshu sharma Do good and cast it into river :)

    Wednesday, May 23, 2012 1:24 PM