Activity Forums Salesforce® Discussions Is there a way to perform validation for apex:inputField?

  • Is there a way to perform validation for apex:inputField?

    Posted by Somendra on August 19, 2019 at 1:41 pm

    I am creating a form in Visualforce. Since my form is a bit long, it is hard for users to remember the error message at the top and revise it. On top of the error message, I want to create a validation when users typing in their information.

    Saddam replied 5 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Saddam

    Member
    August 19, 2019 at 1:57 pm

    Hi Somendra,

    You can add something like this:
    1. Check the Empty
    <apex:page id="page">

    <script>
    function show()
    {
    var name=document.getElementById('page:f1:p1:ip1').value;
    if(name== "" || name==null)
    {
    document.getElementById("page:f1:p1:op2").innerHTML = "Please enter your name";
    }
    }
    </script>

    <apex:form id="f1">
    <apex:pageblock id="p1">
    <apex:outputlabel value="Enter u r name" id="op1" />
    <apex:inputtext id="ip1" />
    <apex:commandbutton value="submit" onclick="return show();" reRender="op2"/>
    <apex:outputlabel id="op2" />
    </apex:pageblock>
    </apex:form>

    </apex:page>

    ---> Besides salesforce has the on field validation, so u can have that option.

    2. create formula syntax
    Regression : '([a-zA-Z0-9_\-\.]+)@(((\[a-z]{1,3}\.[a-z]{1,3}\.[a-z]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3}))'

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos