943,696 Members | Top Members by Rank

Ad:
Aug 17th, 2008
0

JavaScript - Data Validation between two fields

Expand Post »
Hi everyone,

I'm a newbbie on javascript... I'm trying to develope a js to compare the first two letters of two fields... Any help would be appritiated!!!!

Thanks
Chris
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chry_15 is offline Offline
3 posts
since Aug 2008
Aug 19th, 2008
1

Re: JavaScript - Data Validation between two fields

Have a look at this
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function compare () {
  5. var one = document.getElementById('one');
  6. var two = document.getElementById('two');
  7. if ( one.value.substring(0,1) == two.value.substring(0,1) ) {
  8. alert( 'same letter, same case' );
  9. } else if ( one.value.substring(0,1).toLowerCase() ==
  10. two.value.substring(0,1).toLowerCase() ) {
  11. alert( 'same letter, different case' );
  12. } else {
  13. alert( 'different letters' );
  14. }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <form onsubmit="compare()">
  20. <input id="one" type="text" />
  21. <input id="two" type="text" />
  22. <input type="submit" />
  23. </form>
  24. </body>
  25. </html>
Hope it helps
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: img rollover help
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Password field





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC