You need to sign in to do that
Don't have an account?
Aurora 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
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
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>
I would suggest use Javascript.
check this link https://salesforce.stackexchange.com/questions/4499/how-to-make-field-required-via-javascript?rq=1
Thanks
Lokesh