Guest lovexa Posted August 31, 2010 Share Posted August 31, 2010 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title><script language="javascript">function a(){ var ND = document.form1.Noidung.value; var chuoi= "",i=0; //Xử lý khoảng trằng đầu chuỗi if (ND.substring(i,i+1)==" ") while (ND.substring(i,i+1)==" ") i++; //Xử lý trước khi lưu dữ liệu if (chuoi.length ==0) { alert("Nội dung góp ý không được để trống!"); document.form1.Noidung.select(); return false; } else return true; }</script></head><body><form name="form1" method="post" action="" onsubmit="return a()" > <label> <textarea name="Noidung"></textarea> </label> <label> <input type="submit" name="Submit" value="Submit" /> </label> <p> <label></label> </p> </form></body></html>when i enter into the textarea and click on submit button,the message is also alert.please fix this problem.thanks !! Link to comment Share on other sites More sharing options...
dsonesuk Posted August 31, 2010 Share Posted August 31, 2010 because chuoi.length IS zero, var chuoi=""; = 0 var chuoi="notzero"; = 7; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.