diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index e127fa37f4b..3173055a089 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -496,8 +496,10 @@ } var displayname = args.data.displayname; - if(displayname != null && displayname.length > 0) + if(displayname != null && displayname.length > 0) { array1.push("&displayname="+todb(displayname)); + array1.push("&name="+todb(displayname)); + } var group = args.data.groupname; if (group != null && group.length > 0) diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 5a5eb4d11e7..38d9f65cfed 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -9,7 +9,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// Automatically generated by addcopyright.py at 04/03/2012 +// Automatically generated by addcopyright.py at 04/02/2012 var g_mySession = null; var g_sessionKey = null; var g_role = null; // roles - root, domain-admin, ro-admin, user @@ -197,6 +197,20 @@ function isValidJsonString(str) { return true; } +cloudStack.validate = { + vmHostName: function(args) { + // 1 ~ 63 characters long + // ASCII letters 'a' through 'z' (case-insensitive), digits '0' through '9', hyphen ('-') + // must start with a letter + // must end with a letter or a digit (must not end with a hyphen) + var regexp = /^[a-z]{1}[a-z0-9\-]{0,61}[a-z0-9]{0,1}$/; + var b = regexp.test(args); //true or false + if(b == false) + cloudStack.dialog.notice({ message: 'Instance name can not be longer than 63 characters. Only ASCII letters a~z, digits 0~9, hyphen are allowed. Must start with a letter and end with a letter or a digit.' }); + return b; + } +} + cloudStack.preFilter = { createTemplate: function(args) { if(isAdmin()) { diff --git a/ui/scripts/ui-custom/instanceWizard.js b/ui/scripts/ui-custom/instanceWizard.js index 8da07c0f915..5d3cb0f3b1e 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -640,7 +640,17 @@ return false; } } - + + //step 6 - review (spcifiy displyname, group as well) + if ($activeStep.hasClass('review')) { + if($activeStep.find('input[name=displayname]').size() > 0 && $activeStep.find('input[name=displayname]').val().length > 0) { + //validate + var b = cloudStack.validate.vmHostName($activeStep.find('input[name=displayname]').val()); + if(b == false) + return false; + } + } + if (!$form.valid()) { if ($form.find('input.error:visible, select.error:visible').size()) { return false;