By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

get span html in javascript

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

Expand|Select|Wrap|Line Numbers
  1. var spantxt=$('#STATUSCNAME').text();
  2. alert (spantxt);
alert is blank here while it should not be blank
please guide
Apr 11 '17 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
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.
Apr 11 '17 #2

100+
P: 232
Expand|Select|Wrap|Line Numbers
  1.     $.ajax({
  2.                 url: "chksub.php",
  3.                 type: "POST",
  4.                 data:'vchksub='+editableObj.value,
  5.                 success: function(text){
  6.                  msg=text;
  7.                  if(msg=='NO' && $("#STATUS"+vid).html()=='' && editableObj.value!="")
  8.                  {$("#STATUS"+vid).html('<font color="red">*xx!</font>');}}
  9.  
  10.                 });    
results *xx! on span text
Expand|Select|Wrap|Line Numbers
  1. <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
Expand|Select|Wrap|Line Numbers
  1. var valid=$( "#STATUSSUB1" ).text()
while undefined on
Expand|Select|Wrap|Line Numbers
  1. var valid=document.getElementById("STATUSSUB2").text;
  2. alert(valid);
  3.  
irrespective of span text is blank or *xx!
this happens on background check with other table only while all others are working fine
Apr 16 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.