jasmeet Posted August 6, 2013 Share Posted August 6, 2013 <script type="text/javascript" language="javascript"> function checkempty() { if(document.getElementById("title").value=="") { alert("Please enter title."); document.getElementById("title").focus(); return false; } if((document.getElementById("word_count").value>"3000") || (document.getElementById("word_count").value<"400")) { alert("Please enter less than 3000 or more than 400 words."); document.getElementById("word_count").focus(); return false; } return true; } </script> <form method="post" action="" name="my_form" id="theForm" onSubmit="return checkempty();"> <input size="80" id="title" type="text" name="title" value="" /> <textarea id="word_count" name="word_count"></textarea> <input type="submit" name="ok" value="submit" /> /*********this script is not working in the above code **************/ if((document.getElementById("word_count").value>"3000") && (document.getElementById("word_count").value<"400")) { alert("Please enter less than 3000 or more than 400 words."); document.getElementById("word_count").focus(); return false; } i am not good in javascript.. so please can any1 help me???? Link to comment https://forums.phpfreaks.com/topic/280887-validating-number-using-javascript/ Share on other sites More sharing options...
jasmeet Posted August 6, 2013 Author Share Posted August 6, 2013 i use || operator not && operator.. please help!!! Link to comment https://forums.phpfreaks.com/topic/280887-validating-number-using-javascript/#findComment-1443663 Share on other sites More sharing options...
cyberRobot Posted August 6, 2013 Share Posted August 6, 2013 It sounds like you're looking for length property: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length If you're unsure how to use length, there are many resources here: https://www.google.com/search?q=javascript+character+count+textarea For future reference, JavaScript questions should be posted in the JavaScript forum: http://forums.phpfreaks.com/forum/18-jvscript-help/ Link to comment https://forums.phpfreaks.com/topic/280887-validating-number-using-javascript/#findComment-1443664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.