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
isha pisha p 

hi anyone of you plz tell me how to write validation for <input field> in visualforce page using java script?? here is my script ... very new to salesforce

<apex:page standardController="Account"> <script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script> <script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script> <script type="text/javascript"> function validateText(){ var numb="{!Account.AccountNumber}"; alert("Test:"+numb); if(isNaN(parseInt(numb))) { alert("Please only enter numeric characters only ! (Allowed input:0-9)"); return false ; } else return true }; </script> } <apex:form > <apex:pageBlock title="edit accounts for{!$User.LastName}"> <apex:pageBlock title="edit accounts for{!$User.Title}"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Next" action="{!save}" onclick="return validateText();"/> </apex:pageBlockButtons>` <apex:pageBlockSection > <apex:inputField value="{!Account.Site}"/> <apex:inputField value="{!Account.AccountNumber}" /> <apex:inputField value="{!Account.Name}"/> <apex:inputField value="{!Account.NumberOfEmployees}"/> <apex:inputField value="{!Account.Industry}"/> <apex:inputField value="{!Account.Type}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:pageBlock> </apex:form> </apex:page>
karthik R 80karthik R 80
Hi Isha,

Please find the below links hope this will helps you.

http://www.infallibletechie.com/2013/01/how-to-write-javascript-validation-for.html

if it helps you mark it as Best Answer.

Thanks ,
karthik.