diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 8dbf481f38d..b653f98ab4a 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -385,23 +385,14 @@ } }); } - }, - // Step 6: Review - function(args) { - return false; - } - ], - action: function(args) { - /* - var isValid = true; - isValid &= validateString("Name", $thisPopup.find("#wizard_vm_name"), $thisPopup.find("#wizard_vm_name_errormsg"), true); //optional - isValid &= validateString("Group", $thisPopup.find("#wizard_vm_group"), $thisPopup.find("#wizard_vm_group_errormsg"), true); //optional - if (!isValid) - return; - */ - + // Step 6: Review + function(args) { + return false; + } + ], + action: function(args) { // Create a new VM!!!! var array1 = []; @@ -496,8 +487,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) @@ -514,7 +507,7 @@ getUpdatedItem: function(json) { var item = json.queryasyncjobresultresponse.jobresult.virtualmachine; if (item.passwordenabled == true) - alert("Password of new VM " + getVmName(item.name, item.displayname) + " is " + item.password); + alert("Password of new VM " + item.displayname + " is " + item.password); return item; }, getActionFilter: function() { diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 88a8edc2b65..38d9f65cfed 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -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 8faa8cb9b77..128d577482b 100644 --- a/ui/scripts/ui-custom/instanceWizard.js +++ b/ui/scripts/ui-custom/instanceWizard.js @@ -641,6 +641,16 @@ } } + //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;