javascript validation for textbox controls.

1 posts, 0 answers
  1. Raj
    Raj avatar
    33 posts
    Member since:
    Jan 2012

    Posted 09 Feb 2012 Link to this post

    hi friends,
     i doing a validation on client side to insert a values.
    the javascript script validation code are
    function validate() {
     if (document.getElementById("<%=rcmbcurrencycode.ClientID%>").value == "Select") {
                    alert("Currency Code can not be blank");
                    return false;
                }
    if (document.getElementById("<%=rtxtinteresttype.ClientID%>").value == "") {
               alert("Interest Type can not be blank");
               return false;
    }
    }
     
    but my problem is , i can not validated length of the string  and to check numeric or alphabetic for currency and name and age

    i used following snippets of code check the data are characters are not
    var alphaExp = /^[a-zA-Z]+$/;
           if (document.getElementById("<%=rtxtinteresttype.ClientID%>").value == "") {
               alert("Interest Type can not be blank");
               return false;
               if (rtxtinteresttype.value.match(alphaExp)) {
                   return true;
               }
               else {
                   alert("pls enter only numbers");
                   return false;
               }
           }

    but its not working for me.
    can anyone tell me what mistake i have done in this code.
    thanks in advance
    S.Rajkumar
Back to Top