This is a migrated thread and some comments may be shown as answers.

javascript validation for textbox controls.

0 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 09 Feb 2012, 01:27 PM
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

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Raj
Top achievements
Rank 1
Share this question
or