aboutsummaryrefslogtreecommitdiffstats
path: root/nsoc-iui/src/main/resources/webroot/nsoc/js/virtualApplication/validate.js
blob: 9cf00eb2a80915cbed4a47c007132a4d8cc6f814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
$(function(){
	var form = $("#vmAppForm");
	var error = $('.alert-danger', form);
	var success = $('.alert-success', form);

	$.extend($.validator.messages, {
		required: $.i18n.prop("nfv-virtualApplication-iui-validate-inputParam")
	});

	form.validate({
		doNotHideMessage : true,
		errorElement : 'span',
		errorClass : 'help-block',
		focusInvalid : false,
		rules : {
			instanceName : {
				required : true
			},
			serviceTemplateName : {
				required : true
			},
			vimId : {
				required : true
			},
			vnfmId : {
				required : true
			}
		},
		messages : {
			instanceName : {
				required : $.i18n.prop("nfv-virtualApplication-iui-validate-instanceName")
			},
			serviceTemplateName : {
				required : $.i18n.prop("nfv-virtualApplication-iui-validate-serviceTemplateName")
			},
			vimId : {
				required : $.i18n.prop("nfv-virtualApplication-iui-validate-vimId")
			},
			vnfmId : {
				required : $.i18n.prop("nfv-virtualApplication-iui-validate-vnfmId")
			}
		},
		errorPlacement : function(error, element) {
			error.insertAfter(element);
		},
		invalidHandler : function(event, validator) {
			success.hide();
			error.show();
		},
		highlight : function(element) {
			$(element).closest(".form-group").removeClass("has-success").addClass("has-error");
		},
		unhighlight: function (element) {
			$(element).closest(".form-group").removeClass("has-error");
		},
		success : function(label) {
			label.addClass("valid").closest(".form-group").removeClass("has-error");
		},
		submitHandler: function (form) {
			success.show();
			error.hide();
		}
	});
});