You need to sign in to do that
Don't have an account?

I want to check if username is availble or not when i am entered in username texbox by using apex and ajax
Hi
i am new to salesforce i want to please give a sample code for this,please help me out
for reference i have attacthed url please check
like this :http://youhack.me/2010/05/04/username-availability-check-in-registration-form-using-jqueryphp/
please share me code if any one have
i am new to salesforce i want to please give a sample code for this,please help me out
for reference i have attacthed url please check
like this :http://youhack.me/2010/05/04/username-availability-check-in-registration-form-using-jqueryphp/
please share me code if any one have
VF:
<apex:page controller="checkavailability">
<apex:pageBlock >
<apex:form >
<apex:outputtext value="Username"/>
<apex:inputText id="username" value="{!username}"/>
<apex:outputpanel id="ajax">
<apex:commandButton id="checkavailability" action="{!CheckAvailability}" value="Check Availability" rerender="ajax" status="renderstatus"/>
<apex:outputtext id="status" value="{!status}" />
<apex:actionStatus id="renderstatus" startText="Loading..." />
</apex:outputpanel>
</apex:form>
</apex:pageBlock>
</apex:page>
CONTROLLER :
public class checkavailability {
public string status{get; set;}
public String username { get; set; }
public PageReference CheckAvailability() {
if(username==''){
status='enter username';
return null;
}
else{
list<user> users=[select id from user where username=:username];
if(users.size()>0){
status='Not Available';
}
else{
status='Available';
}
return null;
}
}
}
Hope this helps!!