Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check if the Confluence key has been used.
<form class="aui">
AJS.toInit(function() {
AJS.$("#check-key").click(function() {
var validate = /^[0-9a-zA-Z]+$/;
var spacekey = AJS.$("#space-key").val();
if (spacekey.match(validate)) {
url: "/rest/api/space/" + spacekey,
type: "GET",
dataType: "json",
success: function(msg){
alert('No, ' + spacekey + ' has already been used :(');
error: function(err) {
alert('Yes! ' + spacekey + ' is available :)');
else {
alert('Invalid Space Key! It can only contain alphanumeric character (a-z, A-Z, 0-9)');
return false;
<div class="field-group">
<label for="space-key">Check Space Key</label>
<input id="space-key" class="text" type="text">
<button class="aui-button aui-button-primary" id="check-key">Go!</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment