Front end validation #39

Merged
bones7242 merged 5 commits from front-end-validation into master 2017-06-23 20:00:07 +02:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit b48e04f4ac - Show all commits

View file

@ -86,11 +86,21 @@ function dragend_handler(ev) {
/* configure the submit button */
document.getElementById('publish-submit').addEventListener('click', function(event){
event.preventDefault();
var name = document.getElementById('publish-name').value;
var invalidCharacters = /[^\w,-]/.exec(name);
// validate 'name'
if (invalidCharacters) {
alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.');
return;
} else if (name.length < 1) {
alert("You must enter a name for your claim");
return;
}
// make sure a file was selected
if (stagedFiles) {
// make sure only 1 file was selected
if (stagedFiles.length > 1) {
alert("Only one file allowed at a time");
alert("Only one file is allowed at a time");
return;
}
// make sure the content type is acceptable
@ -105,6 +115,8 @@ document.getElementById('publish-submit').addEventListener('click', function(eve
alert("Only .png, .jpeg, .gif, and .mp4 files are currently supported");
break;
}
} else {
alert("Please select a file");
}
})

View file

@ -10,7 +10,7 @@
<div class="col-right">
<textarea id="direct-link-holder" hidden="true">No URL yet</textarea>
<div id="publish-active-area">
<input type="text" id="publish-name" placeholder="Your claim name" class="form-control">
<input type="text" id="publish-name" pattern="[\w,-]" placeholder="Your claim name" class="form-control">
<p>
<label for="publish-license">License:</label>
<br/>