You need to sign in to do that
Don't have an account?
force shahid
Why error msg is not showing ?
Hi Friends,
I write a program on javascript base. When i give the less than 3 letters user name it wil display error msg. But its not working and also F1 is not woking. Please check this code and help me to solve this problem,
Code:
<apex:page >
<script>
function f1(uid,pwd){
var u=document.getElementByid(uid).value;
var p=document.getElementByid(pwd).value;
if(u==""){
alert(' Please enter User name');
document.getelementbyid(uid).focus();
}
else{
if(u.length<3)
alert('Please Enter username minimum 3 Characters');
}
if(p==""){
alert('Please Enter Password');
document.getelementbyid(pwd).focus();
}
}
function f2(uid,pwd){
document.getelementbyid(uid).value="";
document.getelementbyid(pwd).value="";
}
</script>
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title=" Entry Section">
<apex:outputText value="Enter User Name"></apex:outputText>
<apex:inputText id="uid"/>
<apex:outputText value="Enter Password"></apex:outputText>
<apex:inputText id="pwd"/>
<apex:commandButton value="Submit" onclick="f1('{!$component.uid}','{!$component.pwd}')"/>
<apex:commandButton value="CLear" onclick="f2('{!$component.uid}','{!$component.pwd}'"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I write a program on javascript base. When i give the less than 3 letters user name it wil display error msg. But its not working and also F1 is not woking. Please check this code and help me to solve this problem,
Code:
<apex:page >
<script>
function f1(uid,pwd){
var u=document.getElementByid(uid).value;
var p=document.getElementByid(pwd).value;
if(u==""){
alert(' Please enter User name');
document.getelementbyid(uid).focus();
}
else{
if(u.length<3)
alert('Please Enter username minimum 3 Characters');
}
if(p==""){
alert('Please Enter Password');
document.getelementbyid(pwd).focus();
}
}
function f2(uid,pwd){
document.getelementbyid(uid).value="";
document.getelementbyid(pwd).value="";
}
</script>
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection title=" Entry Section">
<apex:outputText value="Enter User Name"></apex:outputText>
<apex:inputText id="uid"/>
<apex:outputText value="Enter Password"></apex:outputText>
<apex:inputText id="pwd"/>
<apex:commandButton value="Submit" onclick="f1('{!$component.uid}','{!$component.pwd}')"/>
<apex:commandButton value="CLear" onclick="f2('{!$component.uid}','{!$component.pwd}'"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
The problem here is JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
we should use statement like below
Please find below code it will work.
Please let me know, if it helps you.
Best Regards,
Dayakar.D
All Answers
The problem here is JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.
we should use statement like below
Please find below code it will work.
Please let me know, if it helps you.
Best Regards,
Dayakar.D