added regex for publish name
This commit is contained in:
parent
b6eb4c076b
commit
b48e04f4ac
2 changed files with 14 additions and 2 deletions
|
@ -86,11 +86,21 @@ function dragend_handler(ev) {
|
||||||
/* configure the submit button */
|
/* configure the submit button */
|
||||||
document.getElementById('publish-submit').addEventListener('click', function(event){
|
document.getElementById('publish-submit').addEventListener('click', function(event){
|
||||||
event.preventDefault();
|
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
|
// make sure a file was selected
|
||||||
if (stagedFiles) {
|
if (stagedFiles) {
|
||||||
// make sure only 1 file was selected
|
// make sure only 1 file was selected
|
||||||
if (stagedFiles.length > 1) {
|
if (stagedFiles.length > 1) {
|
||||||
alert("Only one file allowed at a time");
|
alert("Only one file is allowed at a time");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// make sure the content type is acceptable
|
// 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");
|
alert("Only .png, .jpeg, .gif, and .mp4 files are currently supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
alert("Please select a file");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<div class="col-right">
|
<div class="col-right">
|
||||||
<textarea id="direct-link-holder" hidden="true">No URL yet</textarea>
|
<textarea id="direct-link-holder" hidden="true">No URL yet</textarea>
|
||||||
<div id="publish-active-area">
|
<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>
|
<p>
|
||||||
<label for="publish-license">License:</label>
|
<label for="publish-license">License:</label>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
Loading…
Reference in a new issue