PDA

View Full Version : ajaxFileUpload withjQuery Form validation input text help


rushhh
10-18-2009, 09:22 PM
Never mind, I fingered it out another way. :thumbsup:
-----------------------------------------------------

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