JAVASCRIPT   21

units js

Guest on 8th July 2022 01:28:25 AM

  1.  
  2. var Script = function () {
  3.            alert(0);
  4.     $().ready(function() {
  5.                                            alert(1);
  6.         $("#pgcont").validate({
  7.             rules: {
  8.                                 name: "required",
  9.                 firstname: "required",
  10.                 lastname: "required",
  11.                 username: {
  12.                     required: true,
  13.                     minlength: 2
  14.                 },
  15.                 password: {
  16.                     required: true,
  17.                     minlength: 5
  18.                 },
  19.                 confirm_password: {
  20.                     required: true,
  21.                     minlength: 5,
  22.                     equalTo: "#password"
  23.                 },
  24.                 email: {
  25.                     required: true,
  26.                     email: true
  27.                 },
  28.                 topic: {
  29.                     required: "#newsletter:checked",
  30.                     minlength: 2
  31.                 },
  32.                 agree: "required"
  33.             },
  34.             messages: {
  35.                                      name: "please enter name",
  36.                 firstname: "Please enter your firstname",
  37.                 lastname: "Please enter your lastname",
  38.                 username: {
  39.                     required: "Please enter a username",
  40.                     minlength: "Your username must consist of at least 2 characters"
  41.                 },
  42.                 password: {
  43.                     required: "Please provide a password",
  44.                     minlength: "Your password must be at least 5 characters long"
  45.                 },
  46.                 confirm_password: {
  47.                     required: "Please provide a password",
  48.                     minlength: "Your password must be at least 5 characters long",
  49.                     equalTo: "Please enter the same password as above"
  50.                 },
  51.                 email: "Please enter a valid email address",
  52.                 agree: "Please accept our policy"
  53.             }
  54.                         alert(2);
  55.         });
  56.  
  57.         // propose username by combining first- and lastname
  58.         $("#username").focus(function() {
  59.             var firstname = $("#firstname").val();
  60.             var lastname = $("#lastname").val();
  61.             if(firstname && lastname && !this.value) {
  62.                 this.value = firstname + "." + lastname;
  63.             }
  64.         });
  65.  
  66.         //code to hide topic selection, disable for demo
  67.         var newsletter = $("#newsletter");
  68.         // newsletter topics are optional, hide at first
  69.         var inital = newsletter.is(":checked");
  70.         var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
  71.         var topicInputs = topics.find("input").attr("disabled", !inital);
  72.         // show when newsletter is checked
  73.         newsletter.click(function() {
  74.             topics[this.checked ? "removeClass" : "addClass"]("gray");
  75.             topicInputs.attr("disabled", !this.checked);
  76.         });
  77.     });
  78.  
  79.  
  80. }();

Raw Paste


Login or Register to edit or fork this paste. It's free.