function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aurora Ganguly 10Aurora Ganguly 10 

validation in vf page

Hi all,
I created a vf page , with a text box field mobile number along with a button called Next , so I want when i will give 10 digit number only then only the next button will work, otherwise for giving any number less than 10 digit it should through an error mssg saying plz give the 10digit number?

can any one suggest me the code
Thanks
Raj VakatiRaj Vakati
Hi , 


Please use this code .


<apex:page standardController="Account">
    <apex:form id="myform">
        Mobile No : <apex:inputText id="txtMobId" onblur="return ValidateMobNumber();"/><br></br>
    </apex:form>
    <script type="text/javascript">
        function ValidateMobNumber() {
            var mob = /^(\+91[\-\s]?)\d{10}$/;
            var txtMobile = document.getElementById('{!$Component.myform.txtMobId}');
            if (mob.test(txtMobile.value) == false) {
                alert("Please enter valid mobile number.");
                return false;
            }
            return true;
        }
    </script>
</apex:page>
 
Lokesh KumarLokesh Kumar