Link to home
Start Free TrialLog in
Avatar of Sirdots

asked on

validating a text box using javascript

I have a javascript that reads the value of the firstname
textbox on a form.

If a number was entered I want it to return an alert and
say that you can only enter a string

var vFirstName = document.getElementById("<%= txtFirstName.ClientID %>")

I tried to use the "typeof" something like the code below but its not working

 var vFirstName = document.getElementById("<%= txtFirstName.ClientID %>")
            var getValueFirstName = vFirstName.value
            var result = (typeof getValueFirstName);
            if (result != 'string') {
                alert("First name should be string or letters");
                return false;

please assist
Avatar of COBOLdinosaur
Flag of Canada image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial