You need to sign in to do that
Don't have an account?
street
Page level condition checking
I have a field on Visualforce page( Buying)which contains Amount for eg: 300rps values in rupees.
Now there is a field(Enter amount) on same page(buying)
where the amount to be to entered in it and submit..
Now there should be condition checking on pagelevel that Enter amount field should be less than Amount.
I need this to check on page Enter amount <= amount
HOw can i check on page itself. tried action support using onchange on field Enter amount.
Any help will be thankfull.
Hi,
Try the below code snippet as reference:
--------------- Vf page---------------
<apex:page controller="chekamountonpage" >
<script>
var flag=false;
function chekamount(val)
{
var inputtextvalue=val.value;
var buyingvalue='{!buying}';
if(inputtextvalue.length>0)
{
if(inputtextvalue<=buyingvalue)
{
flag=true;
}
else
{
flag=false;
}
}
}
function callonsubmit()
{
if(flag)
{
return flag;
}
else
{
alert('Please enter a valid amount');
return flag;
}
}
</script>
<apex:form >
<apex:inputText value="{!inputamount}" onblur="chekamount(this)"/>
<apex:commandButton value="Save" onclick="return callonsubmit()"/>
</apex:form>
</apex:page>
---------------- Apex controller ----------------
public class chekamountonpage
{
public integer Buying{get;set;}
public integer inputamount{get;set;}
public chekamountonpage ()
{
Buying=300;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi,
You can also try the following:
<apex:outputPanel >
<apex:inputText value="{!contact.FirstName}" >
<apex:actionSupport event="onchange" action="{!validateFirstName}"/>
</apex:inputText>
</apex:outputPanel>
public pagereference validateFirstName()
{
if(cont.FirstName == 'aaaa')
return new pagereference('apex/testing1');
else
return null;
}
Thanks
I need it on page level....i cant use controller for this requirement.