get span html in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    get span html in javascript

    Code:
    <span id="STATUSCNAME"></span>
    javascript
    Code:
    if((editableObj.value=="" || editableObj.value.length>32 || regexname.test(editableObj.value)==false))
    	{$("#STATUSCNAME").html('<font color="red">*Required alphabets upto 32 characters!</font>');}
    	else{$("#STATUSCNAME").html('');}
    	}
    both working but on submit i want to check validation that all span should be blank.the same is not retrieving the result

    Code:
    var spantxt=$('#STATUSCNAME').text();
    alert (spantxt);
    alert is blank here while it should not be blank
    please guide
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Why should it not be blank?

    you should post a link to your page, as there is not enough information here to solve this problem.

    Comment

    • kkshansid
      New Member
      • Oct 2008
      • 232

      #3
      Code:
      	$.ajax({
      				url: "chksub.php",
      				type: "POST",
      				data:'vchksub='+editableObj.value,
      				success: function(text){
      				 msg=text;
      				 if(msg=='NO' && $("#STATUS"+vid).html()=='' && editableObj.value!="")
      				 {$("#STATUS"+vid).html('<font color="red">*xx!</font>');}}
      				 
      				});
      results *xx! on span text
      Code:
      <TD>SUBJECT1:</TD><TD><input type="text" onBlur="validatehu(this)" name="SUB1" id="SUB1" value="<?php echo $SUB1;?>"><span id="STATUSSUB1"></span></TD></TR>
      but on final submit while checking all span text
      but becomes blank on
      Code:
      var valid=$( "#STATUSSUB1" ).text()
      while undefined on
      Code:
      var valid=document.getElementById("STATUSSUB2").text;
      alert(valid);
      irrespective of span text is blank or *xx!
      this happens on background check with other table only while all others are working fine

      Comment

      Working...