jquery validation

I've done it again and need custom validation using jquery and so I'm writing it. Given my form is custom as are the data tables backing the required system are there any easily added libraries that I can queue for this?

  • 2TechGirls

    i can post what i am working on now if this is something that would need to be developed. I was really looking for a recomendatiom for a general jQuery validation that is accepted as recommended for word press.
    jQuery this is being queued. and the form is after this.

    right now its just checking for required.

    /**
     * Created with JetBrains PhpStorm.
     * User: Kim Schroeder
     * Date: 4/6/13
     * Time: 1:32 PM
     * To change this template use File | Settings | File Templates.
     */
    (function($) {
    
    	// $ Works! You can test it with next line if you like
    	// console.log($);
        var req="first_name,last_name";
    
       $('input[name=presentationtype]:radio').change(function() {
           var i=this;
           // worked on as of posting
       });
    
    	$('#proposed_presentation_submit').click(function(){
            var rtn = true;
            var frm = $("#frm1 :input");
              //Do something amazing...
            $(frm).each(function(){
              //  var ths = $(this);
                var nme =$(this).attr('name') + '_req';
                var req = $.find('#' + nme);
                var inputval = $(this).attr('value');
                if (req != ''){
                    var yes =1;
                    if($(this).attr('value') == '')
                        {
                            $(req).show();
                            rtn=false;
                        }
                }
                else {
                    var yes=0;
                }
                var x=0;
            });
    
    	    return rtn;
    	});
    
    })( jQuery );
    
    // here is the html/php i'm not including the class i'm using as a data object
    <?php
    /**
     * Created by JetBrains PhpStorm.
     * User: Kim
     * Date: 4/6/13
     * Time: 11:42 AM
     * To change this template use File | Settings | File Templates.
     */
    
    $pageURL .= "http://" .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    $rm = new twotg_conference_proposal();
    $rm->first_name = $_REQUEST["first_name"];
    $rm->last_name = $_REQUEST["last_name"];
    $rm->company_name = $_REQUEST["company_name"];
    $rm->title = $_REQUEST["title"];
    $rm->email = $_REQUEST["email"];
    $rm->presentation_title = $_REQUEST["presentation_title"];
    $rm->presentation_content_tags = $_REQUEST[""];
    $rm->presentation_type = $_REQUEST["presentation_type"];
    
    function setcolwidth(){
        echo 70;
    }
    ?>
    
    <div class="speaker">
    <form name="presentation_proposal" id="frm1" action="<?php echo $pageURL ?>" method="post">
    <table>
        <h2>Propose a Talk</h2>
        <tr>
            <tr><td colspan="2">Name of person submitting presentation.<div id="first_name_star"*</div></td></tr>
        <tr>
            <td>
            <input type="text" name="first_name" value="<?php echo $rm->first_name; ?>" /><div id="first_name_req">* first name is required</div>
            </td>
            <td>
                <input type="text" name="last_name"  value="<?php echo $rm->last_name; ?>"  /><div id="last_name_req">* last name is required</div>
            </td>
        </tr>
        <tr>
            <td colspan="2">Company Name*</td>
        </tr>
        <tr>
            <td><input type="text" name="company_name" value="<?php echo $rm->company_name; ?>"  /><div id="company_name_req">* company name is required</div></td>
          </tr>
        <tr>
            <td colspan="2">Title*</td>
        </tr>
        <tr>
            <td><input type="text" name="title" /></td>
        </tr>
  • Paul

    @2TechGirls,

    Greetings. You hadn't provided any details on your form so somewhat hard to make a recommendation on a form validation jQuery solution. I've not personally used a jQuery plugin to validate form as I find it easier to roll my own than fight with some other developer's logic.

    You can probably just search for something
    https://www.google.com/search?client=safari&rls=en&q=jQuery+form+validation+plugin&ie=UTF-8&oe=UTF-8

    Give more details on your form and the types of fields and can probably provide a more detailed answer.

    Also, you mentioned the backend database. Since I'm assuming you will be sending the form data to the server where some PHP script will insert the records into the database table. You will probably then be double validating the form. For two sets of business logic. Once in the client side (browser) JavaScript. And second on the server (PHP). Might be more streamline to just send the form for fields via AJAX and have the validation done all via server-side PHP logic. Just a thought.

  • aecnu

    Greetings 2TechGirls,

    With the lead developers last post, it appears this particular topic is now resolved/closed, if you need any further assistance please let us know.

    If it wasn't resolved, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.