JavaScript - Data Validation between two fields

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Aug 2008
Posts: 3
Reputation: chry_15 is an unknown quantity at this point 
Solved Threads: 0
chry_15 chry_15 is offline Offline
Newbie Poster

JavaScript - Data Validation between two fields

 
0
  #1
Aug 17th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 381
Reputation: langsor is an unknown quantity at this point 
Solved Threads: 33
langsor langsor is offline Offline
Posting Whiz

Re: JavaScript - Data Validation between two fields

 
1
  #2
Aug 19th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC