Guest User

Untitled

a guest
Aug 14th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <div class="loginForm">
  2. <form action="index.php?page=register&add=true" method="post">
  3. <ul style="list-style-type:none">
  4. <li>Username: <input type="text" name="username" /> <span class="error"></span></li>
  5. <li>Password: <input type="password" name="password" /> <span class="error"></span></li>
  6. <li>Real name: <input type="text" name="name" /> <span class="error"></span></li>
  7. <li>Seat number: <input type="text" name="seat" /> <span class="error"></span></li>
  8. <li>Game/Steam name: <input type="text" name="steam" /> <span class="error"></span></li>
  9. </ul>
  10. <input type="submit" value="Register" />
  11. </form>
  12. Already registered? Click <a href="index.php?page=login">here</a> to login
  13. </div>
  14. <script type="text/javascript">
  15. /* should probably be moved to the head */
  16. $(document).ready(function() {
  17. function setError(obj,message) {
  18. if (!message) {
  19. $(obj).css('background-color','#ccffcc');
  20. $(obj).siblings('.error').fadeOut('slow');
  21. }
  22. else {
  23. $(obj).css('background-color','#ff8888');
  24. $(obj).siblings('.error').html(message).fadeIn('slow');
  25. }
  26. }
  27. $('.loginform input[type=text]').change(function() {
  28. var inputText = $(this).val();
  29. var inputName = $(this).attr('name');
  30. //Validation
  31. if ($(this).attr('name') !== 'name'
  32. && inputText.indexOf(" ") != -1) {
  33. //spaces in username/seat/steam
  34. setError(this,'No spaces please!');
  35. }
  36. else { if ($(this).attr('name') == 'seat') {
  37. //Seat Number
  38. var r = /^[a-f]1?[1-9]$/i;
  39. if (!r.test(inputText)) {
  40. setError(this,'invalid seat number! (A1-F19)');
  41. }
  42. else {
  43. //alphanumerics
  44. var r = /^[a-z 0-9]+$/i;
  45. if (!r.test(inputText)) {
  46. setError(this,'alphanumeric only please!(a-z, 0-9)');
  47. }
  48. else {
  49. setError(this);
  50. }
  51. }
  52. }
  53. }
  54. });
  55. });
  56. </script>
Add Comment
Please, Sign In to add comment