Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
We are developing one mobile application. It contains customer address information. In address inforamtion i have zip,phone number all are textboxes. I need number and alphabets validation for this. I try like this
C#
function onlyNos(e) {
            var evt = (e) ? e : window.event;
           var charCode = (evt.keyCode) ? evt.keyCode : evt.which;
           if (charCode > 31 && (charCode < 48 || charCode > 57)) {
               return false;
           }
           return true;
        };

        function onlyAlphabets(e, t) {
            try {
                if (window.event) {
                    var charCode = window.event.keyCode;
                }
                else if (e) {
                    var charCode = e.which;
                }
                else { return true; }
                if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123))
                    return true;
                else
                    return false;
            }
            catch (err) {
                alert(err.Description);
            }
        };


@Html.TextBoxFor(model => model.LastName, new { @onkeypress = "return onlyAlphabets(event,this);" })
@Html.TextBoxFor(model => model.ZipPostalCode, new { @onkeydown = "return onlyNos(this);", minlength = "5", maxlength = "10", size = "10" })

But it is not working in mobile apps. Normal desktop its working fine but in mobile views it no working.
Can any one help me to do this textbox validations in mobile views.
Posted
Comments
Richard MacCutchan 9-Oct-14 3:59am    
I have deleted your duplicate of this question; please post once only.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900