Link to home
Start Free TrialLog in
Avatar of kousis
kousis

asked on

checking the value in textbox

hi
I 've got textfield, while entering the text, it should check for the each and every alphabet and should give message if alphabet is repeated
 
for eg. if i am entering "alpha" it should give alert message while entering the "a" second time.

TIA
ASKER CERTIFIED SOLUTION
Avatar of CJ_S
CJ_S
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michel Plungjan
You may want to do
for(i=0;i<val.length;i++) {
  ch = val.charAt(i).toLowerCase();
  if(alfabet.indexOf(ch)>=0) {
     alert("Invalid character: "+val.charAt(i))
     return false;
   }
   alfabet += ch;
}


Michel
in case you do NOT want it case sensitive
Michel,
not to criticize you. But do you remember the conversaion we had about this a long time ago. And that we both agreed on not "steeling" each others "answers"? Because that is what you are doing right now. I'm not going to defend myself after your comment...but I'd appreciate it if you too would keep that in mind.

Regards,
CJ
1. I am not steeling since I am only adding to your code, not posting a new version
2. If you really want to we can discuss how many questions you manage to put your clammy little hands on lately. It could be hard to get the points to stay in the advanced ee with you around ;-)

Michel
1) True...
2) Not true... I have big hands, but even then it's not true. The thing was that we had a deal, and the only recent question that I can recall that I jumped in a question in which you were active was something about an onload function not being called due to the <!-- and //-->. Which was a totally different comment than any of yours.

Again, I am not critizing, but just reminding. I don't feel anything for an argument.

regards,
CJ
Comments are always welcome - it is complete pieces of code that bothers me more - and only if they are variations and then gets accepted as answers

Michel

Michel,
but that's exactly what you have just done. You might see it as an addition to my comment, but still it's a complete piece of code.
additional addition: it's a complete piece of code which is the same as I wrote but with one change...
I mean something like this:


<html>
<head>
 <script>
  function validate(tObj)
  {
     var alfabet="";
     var val = tObj.value;
     for(i=0;i<val.length;i++)
     {
        ch = val.charAt(i).toLowerCase();
        if(alfabet.indexOf(ch)>=0)
        {
           alert("Invalid character: "+val.charAt(i))
           return false;
        }
        alfabet += ch;
     }
  }
 </script>
</head>

<body>
 <form name="myForm">
  <input type="text" onKeyUp="validate(this)">
 </form>
</body>
</html>


Just posting a changed function is not what I meant.
You are being a bit protective today huh?

Kousis: Please forgive our discussion and accept CJ's answer.

Michel
Michel,
I'm not going to argue...
<observation>
  lounge might be a better place for this discussion than in a Q.
</observation>

Cd&

Avatar of klaetu
klaetu

This question is still open today, waiting for your response.

Please finalize this question, or update us as to what else you need.  There are several working comments and you have several open questions.

Thank you very much.  Your attention to this is appreciated so others may benefit from this question,
once finalized, since it will move to our PAQ and others can find help from this as well.  

Klaetu
moderator @ experts-exchange
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange