Skip to content

Commit

Permalink
add rules to validator. rockstor#560
Browse files Browse the repository at this point in the history
  • Loading branch information
priyaganti committed Apr 17, 2016
1 parent 195fdd2 commit 66ba2c9
Showing 1 changed file with 48 additions and 3 deletions.
Expand Up @@ -111,7 +111,7 @@ NewNetworksView = Backbone.View.extend({
errPopupContent.html(msg);
statusEl.click(function(){ errPopup.overlay().load(); });
},

deleteConnection: function(event){
alert("Are you sure to delete the connection?");
var _this = this;
Expand All @@ -122,7 +122,7 @@ NewNetworksView = Backbone.View.extend({
$.ajax({
url: "/api/network/connections/" + connectionId,
type: "DELETE",
dataType: "json",
dataType: "json",
success: function() {
_this.collection.fetch({reset: true});
enableButton(button);
Expand Down Expand Up @@ -186,6 +186,50 @@ NewNetworkConnectionView = RockstorLayoutView.extend({
}));

this.validator = this.$("#new-connection-form").validate({
onfocusout: false,
onkeyup: false,
rules: {
name: "required",
ipaddr: {
required: {
depends: function(element) {
return (_this.$('#method').val() == 'manual')
}
}
},
gateway: {
required: {
depends: function(element){
return (_this.$('#method').val() == 'manual')
}

}
},
teamprofile: {
required: {
depends: function(element){
return (_this.$('#ctype').val() == 'team')
}

}
},
bondrofile: {
required: {
depends: function(element){
return (_this.$('#ctype').val() == 'bond')
}

}
},
devices: {
required: {
depends: function(element){
return (_this.$('#ctype').val() == 'team')
}

}
},
},
submitHandler: function() {
var button = _this.$('#submit');
if (buttonDisabled(button)) return false;
Expand Down Expand Up @@ -248,7 +292,6 @@ NewNetworkConnectionView = RockstorLayoutView.extend({
placement: 'right',
title:"A comma separated list of DNS search domains."
});

},

// hide fields when selected method is auto
Expand Down Expand Up @@ -277,6 +320,8 @@ NewNetworkConnectionView = RockstorLayoutView.extend({
}
},



cancel: function(event) {
event.preventDefault();
app_router.navigate("network2", {trigger: true});
Expand Down

0 comments on commit 66ba2c9

Please sign in to comment.