+ Start a Discussion
Naresh Kumar 7Naresh Kumar 7 

How to compare inputField value with string on VF page?

Can any one plz tell me

how we can compare input field value with String on VF page.
sharathchandra thukkanisharathchandra thukkani
You can do that in javascript....If you have controller associated with it then you can do in class also.

Something like this might work for you.This code is not tested. 

function compareString(){
    var strElement = document.getElementById('{!$Component.validateString.name}').value;
    if(strelemt == 'check')
          return true
return false;

<apex:form id='validateString'>
    <apex:commandButton id="save"  onclick="javascript:compareString()"/>
    <apex:inputfield id='validateString' >