Skip to content

Instantly share code, notes, and snippets.

@tim-kos
Created July 3, 2011 20:36
Show Gist options
  • Save tim-kos/1062581 to your computer and use it in GitHub Desktop.
Save tim-kos/1062581 to your computer and use it in GitHub Desktop.
<link rel="stylesheet" type="text/css" href="http://assets.transloadit.com/css/transloadit2.css" />
<script type="text/javascript">
$(document).ready(function() {
var bypassValidationAndTlBinding = false;
$("#MyForm").submit(function( e) {
if (!bypassValidationAndTlBinding) {
if( $("#firstname").val() != "dan" ) {
alert("the name is not dan");
e.preventDefault()
} else {
alert("form is valid... now how come there is no progress bar after you hit ok? it still seems to upload to S3 though...");
e.preventDefault()
$("#MyForm").transloadit({
wait: true,
});
bypassValidationAndTlBinding = true;
$('#MyForm').submit();
}
}
});
});
</script>
</head>
<body>
<h2>This should only submit if you enter dan in the FirstName textbox.</h2>
<?php
$params = array(
'auth' => array('key' => 'YOUR KEY'),
'template_id' => 'TEMPLATE_ID'
);
?>
<form id="MyForm" action="http://mydomain.com/transloadit.post.php" enctype="multipart/form-data" method="POST">
<input type='hidden' name='params' value="<?php echo htmlentities(json_encode($params)) ?>" /><br />
FirstName: <input type="text" name="firstname" id="firstname" ><br /><br /><br />
<input type="file" name="my_file" /><br /><br />
<input type="submit" value="Submit" id="submitform">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment