Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ajaxFileUpload with jQuery Form validation input text help

    Hi, For the last few days been tring to design jQuery Form validation text box with ajax upload

    Basic I'm trying to input text in a text box and upload a file. On the back end file it check the database to see if Lastname has already been enter, If the username hasn't been add, it then insert to the the datebase with the new username and uploads the image as well.

    [CODE]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
    <script type="text/javascript" src="http://www.phpletter.com/contents/ajaxfileupload/ajaxfileupload.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("#myform").validate({

    //errorLabelContainer: "#messageBox",
    //wrapper: "li",
    rules: {
    username : {
    required: true,
    minlength: 5,
    remote: {
    url: "test13.php",
    type: "post",
    data: {
    type: "text",
    username : function() { return $("#username ").val()},
    }
    }

    }

    },
    messages: {
    username : {
    required: "Please provide a username",
    minlength: "Your username must be at least 5 characters long",
    remote: jQuery.format("Sorry but '{0}' has already been selected. Please try again.")
    }
    },
    submitHandler: function(form) {
    $.ajaxFileUpload
    (
    {
    url:'test13.php',
    secureuri:false,
    fileElementId:'fileToUpload',
    dataType: 'json''


    }
    )
    return false;
    }
    });

    });
    </script>

    </head>
    <body>
    <ul id="messageBox"></ul>

    <form id="myform" action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
    <input type="hidden" name="fileframe" value="true">
    <label> username </label>
    <input name="lname" id="username " title="Your username , please!" class="required" />
    <br/>
    <input type="file" name="fileToUpload" id="fileToUpload" class="input">
    <br />
    <input type="submit" value="Submit"/>
    </form>

    </body>
    </html>
    [CODE]

    Thanks

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    What does the code above do? Is it online anywhere we can see it?

  • #3
    New Coder
    Join Date
    Sep 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Never mind, I fingered it out another way.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •