summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--install/static/details.js29
-rw-r--r--install/static/test/data/json_metadata.json6
2 files changed, 26 insertions, 9 deletions
diff --git a/install/static/details.js b/install/static/details.js
index 312ad950..d0688f55 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -123,6 +123,7 @@ function ipa_stanza(spec){
var value = $.trim(input.val());
if (!value) value = '';
+
values.push(value);
});
@@ -480,20 +481,34 @@ function _ipa_create_text_input(attr, value, param_info)
return index;
}
+ function validate_input(text, param_info,error_link){
+ if(param_info && param_info.pattern){
+ var regex = new RegExp( param_info.pattern );
+ if (!text.match(regex)) {
+ error_link.style.display ="block";
+ if ( param_info.pattern_errmsg){
+ error_link.innerHTML = param_info.pattern_errmsg;
+ }
+ }else{
+ error_link.style.display ="none";
+ }
+ }
+ }
+
var input = $("<Span />");
input.append($("<input/>",{
type:"text",
name:attr,
value:value.toString(),
- keypress: function(){
- var validation_info=param_info;
+ keyup: function(){
var undo_link=this.nextElementSibling;
undo_link.style.display ="inline";
- if(false){
- var error_link = undo_link.nextElementSibling;
- error_link.style.display ="block";
- }
+ var error_link = undo_link.nextElementSibling;
+
+ var text = $(this).val();
+ validate_input(text, param_info,error_link);
}
+
}));
input.append($("<a/>",{
html:"undo",
@@ -515,6 +530,8 @@ function _ipa_create_text_input(attr, value, param_info)
this.previousElementSibling.value = previous_value;
this.style.display = "none";
+ var error_link = this.nextElementSibling;
+ validate_input(previous_value, param_info,error_link);
}
}));
input.append($("<span/>",{
diff --git a/install/static/test/data/json_metadata.json b/install/static/test/data/json_metadata.json
index 8571ddf6..a005d1d5 100644
--- a/install/static/test/data/json_metadata.json
+++ b/install/static/test/data/json_metadata.json
@@ -1098,8 +1098,8 @@
"minlength": null,
"multivalue": false,
"name": "description",
- "pattern": null,
- "pattern_errmsg": null,
+ "pattern": "^[a-zA-Z-2-9_. ]{0,30}[a-zA-Z0-9_.$-]?$",
+ "pattern_errmsg": "may only include letters, numbers, _, -, . and $",
"primary_key": false,
"query": false,
"required": true,
@@ -4474,4 +4474,4 @@
}
}
}
-} \ No newline at end of file
+}