You need to sign in to do that
Don't have an account?
sandeep kumar 1996
Need jquery validations for search and clear buttons of my vf page
vf page:
<apex:page standardController="account" extensions="accsearchcontroller" sidebar="false">
<apex:form id="formID">
<apex:actionFunction name="searchtext" action="{!search}"/>
<apex:pageBlock >
<apex:pageBlocksection title="Accounts" columns="1">
<apex:inputText value="{!searchstring}" label="Account number" id="sh" html-placeholder="Please enter account number" />
<p class="search">please enter account number</p>
</apex:pageBlocksection>
<apex:commandButton value="Search" action="{!search}"/>
<apex:commandButton value="Clear" id="clear" action="{!clear}"/> <!-- action="{!clear}" -->
</apex:pageBlock>
<apex:pageBlock id="resultPanel">
<apex:pageblockTable value="{!acc}" var="a" id="TT">
<apex:column >
<apex:facet name="header"> Employee Name </apex:facet>
<apex:outputLink value="/{!a.id}" id="hh" target="_Blank"> {!a.name} </apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header"> Employee Number</apex:facet>
{!a.AccountNumber}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
controller:
public with sharing class accsearchcontroller {
public list <account> acc {get;set;}
public string searchstring {get;set;}
public accsearchcontroller(ApexPages.StandardController controller) {
}
public void search(){
string searchquery='select AccountNumber,name,id,Type from account where AccountNumber like \'%'+searchstring+'%\'';
acc= Database.query(searchquery);
}
public void clear()
{
acc.clear();
}
}
<apex:page standardController="account" extensions="accsearchcontroller" sidebar="false">
<apex:form id="formID">
<apex:actionFunction name="searchtext" action="{!search}"/>
<apex:pageBlock >
<apex:pageBlocksection title="Accounts" columns="1">
<apex:inputText value="{!searchstring}" label="Account number" id="sh" html-placeholder="Please enter account number" />
<p class="search">please enter account number</p>
</apex:pageBlocksection>
<apex:commandButton value="Search" action="{!search}"/>
<apex:commandButton value="Clear" id="clear" action="{!clear}"/> <!-- action="{!clear}" -->
</apex:pageBlock>
<apex:pageBlock id="resultPanel">
<apex:pageblockTable value="{!acc}" var="a" id="TT">
<apex:column >
<apex:facet name="header"> Employee Name </apex:facet>
<apex:outputLink value="/{!a.id}" id="hh" target="_Blank"> {!a.name} </apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header"> Employee Number</apex:facet>
{!a.AccountNumber}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
controller:
public with sharing class accsearchcontroller {
public list <account> acc {get;set;}
public string searchstring {get;set;}
public accsearchcontroller(ApexPages.StandardController controller) {
}
public void search(){
string searchquery='select AccountNumber,name,id,Type from account where AccountNumber like \'%'+searchstring+'%\'';
acc= Database.query(searchquery);
}
public void clear()
{
acc.clear();
}
}
If you want to apply required field validation then see the following link.
https://sfcure.wordpress.com/2017/01/28/vfvalidator-form-validation-in-visualforce-page/