You need to sign in to do that
Don't have an account?
How to check the password Validation.
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;
}
}
Hi,
can u try this below code,
<apex:page controller="pwdvaldcon" id="pg1">
<apex:form id="frm">
<apex:pageBlock id="pbk">
<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}" onclick="validate();"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<script>
function validate()
{
var myname=document.getElementById("{!$Component.pg1.frm.pbk.pbs.pn}").value;
var mypwd=document.getElementById("{!$Component.pg1.frm.pbk.pbs.pp}").value;
if(mypwd!=null)
{
alert("You Entered"+myname);
}
else
{
alert("Would you please enter some text?");
}
</script>
Tnq for ur reply..wil try tat code.