• Rosy09
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies

Hi..

 

Am trying for password validation using javascript in apex class.But i dont know where i went wrong .Can anyone please go through the below  code and let me know my mistake.

 

Thanks in advance.

 

<apex:page controller="pwdvaldcon">
<script>
function validate(){

var myTextField = document.getElementById('pp');
if(myTextField.value != "")
alert("You entered: " + myTextField.value)
else
alert("Would you please enter some text?")
}
</script>

<apex:form id="frm">
<apex:pageBlock id="pg">
<apex:pageBlockSection id="pbs">
<apex:inputText value="{!name}" label="Name" id="pn"/>
<apex:inputText value="{!pwd}" label="password" id="pp"/>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

     

Controller:

 

   

public with sharing class pwdvaldcon {

public String name { get; set; }
public String pwd { get; set; }
public new_account__c na {get;set;}



public pwdvaldcon(){
na = new new_account__c();

}
public PageReference save() {
na.password__c = pwd;
na.name=name;

insert na ;
return null;
}

}