Below script is to validating the blank fields:
<script language="javascript" type="text/javascript"
>function isBlank(s) {<script language="javascript" type="text/javascript"
if (s == null)
return true;
if (s.match(/^\s*$/)) {
return true}return false;}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);}
function ltrim(str, chars) {chars = chars ||
"\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");}
function rtrim(str, chars) {chars = chars ||
"\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");}
</script>
e.g:
if (isBlank(trim(objPrice.value, ' ')) || trim(objPrice.value, ' ').length == 0) {
alert(
"Please enter Price.");document.getElementById(price).focus();
return false;}
No comments:
Post a Comment