Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Validation

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Validation

    Hi guys i am trying to do some validation in application form.

    I have 3 text box for different mobile numbers like home, work, Mobile like this.. i need 1 field compulsory of 3. User must have to enter at least 1 number of 3. i m using below script for other fields.

    Is there other way to do this?

    <script type="text/javascript">

    $().ready(function() {

    // validate signup form on keyup and submit
    $("#signupForm").validate({
    rules: {


    firstname: "required",
    lastname: "required",
    pasteresume:"required",
    skill:"required",
    username: {
    required: true,
    minlength: 2
    },
    email: {
    required: true,
    email: true
    },
    phone: {
    required: true

    },
    topic: {
    required: "#newsletter:checked",
    minlength: 2
    },
    agree: "required"
    },
    messages: {
    firstname: "Please enter your firstname",
    lastname: "Please enter your lastname",
    pasteresume: "Please enter paste your Resume",
    skill: "Please enter your Key Skill",
    username: {
    required: "Please enter a username",
    minlength: "Your username must consist of at least 2 characters"
    },
    password: {
    required: "Please provide a password",
    minlength: "Your password must be at least 5 characters long"
    },
    confirm_password: {
    required: "Please provide a password",
    minlength: "Your password must be at least 5 characters long",
    equalTo: "Please enter the same password as above"
    },
    email: "Please enter a valid email address",
    phone: "Please enter a valid phone number",
    agree: "Please accept our policy"
    }
    });

    // propose username by combining first- and lastname
    $("#username").focus(function() {
    var firstname = $("#firstname").val();
    var lastname = $("#lastname").val();
    if(firstname && lastname && !this.value) {
    this.value = firstname + "." + lastname;
    }
    });

    //code to hide topic selection, disable for demo
    var newsletter = $("#newsletter");
    // newsletter topics are optional, hide at first
    var inital = newsletter.is(":checked");
    var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
    var topicInputs = topics.find("input").attr("disabled", !inital);
    // show when newsletter is checked
    newsletter.click(function() {
    topics[this.checked ? "removeClass" : "addClass"]("gray");
    topicInputs.attr("disabled", !this.checked);
    });
    });


    </script>
    Last edited by Dipali86; October 29th, 2012 at 07:51 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Validation

    My first suggestion would be to read the announcement post that is marked If it is your first time hear please read. It describes how javascript is not equal to java. Given these are java forums, I'd recommend trying your luck on a javascript forum. It also describes to choose your forum topic carefully...thread moved out of the Members Introductions

Similar Threads

  1. Validation for SpecialCharacter
    By surendran610 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: August 29th, 2011, 03:00 PM
  2. Help With Validation
    By bengregg in forum Loops & Control Statements
    Replies: 4
    Last Post: February 1st, 2011, 04:24 AM
  3. Jtextfield Validation
    By nimishalex in forum AWT / Java Swing
    Replies: 8
    Last Post: December 11th, 2010, 02:42 AM
  4. Code Validation help??
    By kmh90210 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 30th, 2010, 11:25 AM
  5. Problems with If validation
    By websey in forum Loops & Control Statements
    Replies: 1
    Last Post: November 18th, 2009, 09:43 AM