Commit 8c653fdc authored by Ryan Herbert's avatar Ryan Herbert
Browse files

better date validation pattern

parent d900d7f2
...@@ -113,7 +113,7 @@ FormBuilder.prototype.build_date = function(id, object, name, label) { ...@@ -113,7 +113,7 @@ FormBuilder.prototype.build_date = function(id, object, name, label) {
var d = this.build_wrapper(); var d = this.build_wrapper();
d.appendChild(this.build_label(label, object, id)); d.appendChild(this.build_label(label, object, id));
var i = this.build_input(id, 'date', name, 'text', object, false, 'yyyy-mm-dd'); var i = this.build_input(id, 'date', name, 'text', object, false, 'yyyy-mm-dd');
i.pattern = "[0-9]{4}-[0-9]{2}-[0-9]{2}"; i.pattern = "(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))";
i.title = "yyyy-mm-dd" i.title = "yyyy-mm-dd"
d.appendChild(i); d.appendChild(i);
return d; return d;
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
<label for="sampling_date_{{=i}}" id="sampling_date__label_{{=i}}">sampling date: </label> <label for="sampling_date_{{=i}}" id="sampling_date__label_{{=i}}">sampling date: </label>
<input class="date form-control" id="sampling_date_{{=i}}" name="file[{{=i}}][sampling_date]" type="text" <input class="date form-control" id="sampling_date_{{=i}}" name="file[{{=i}}][sampling_date]" type="text"
value="{{if 'sampling_date' in file and file['sampling_date'] is not None:}}{{=file['sampling_date']}}{{pass}}" value="{{if 'sampling_date' in file and file['sampling_date'] is not None:}}{{=file['sampling_date']}}{{pass}}"
placeholder="yyyy-mm-dd" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}"> placeholder="yyyy-mm-dd" pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))">
</div> </div>
<div class="field_div"> <div class="field_div">
<label for="file_info_{{=i}}" id="file_info__label_{{=i}}">info: </label> <label for="file_info_{{=i}}" id="file_info__label_{{=i}}">info: </label>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<label for="patient_birth_{{=i}}" id="patient_birth__label_{{=i}}">Birth:</label> <label for="patient_birth_{{=i}}" id="patient_birth__label_{{=i}}">Birth:</label>
<input class="date form-control" id="patient_birth_{{=i}}" name="patient[{{=i}}][birth]" type="text" <input class="date form-control" id="patient_birth_{{=i}}" name="patient[{{=i}}][birth]" type="text"
value="{{if set is not None and set['birth'] is not None:}}{{=set['birth']}}{{pass}}" value="{{if set is not None and set['birth'] is not None:}}{{=set['birth']}}{{pass}}"
placeholder="yyyy-mm-dd" title="yyyy-mm-dd" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}"> placeholder="yyyy-mm-dd" title="yyyy-mm-dd" pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))">
</div> </div>
<div class="field_div"> <div class="field_div">
<label for="patient_info_{{=i}}" id="patient_info__label_{{=i}}">Info:</label> <label for="patient_info_{{=i}}" id="patient_info__label_{{=i}}">Info:</label>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<label for="run_date_{{=i}}" id="run_date__label_{{=i}}">Date:</label> <label for="run_date_{{=i}}" id="run_date__label_{{=i}}">Date:</label>
<input id="run_date_{{=i}}" name="run[{{=i}}][run_date]" type="text" class="date form-control" <input id="run_date_{{=i}}" name="run[{{=i}}][run_date]" type="text" class="date form-control"
value="{{if set is not None and set['run_date'] is not None:}}{{=set['run_date']}}{{pass}}" value="{{if set is not None and set['run_date'] is not None:}}{{=set['run_date']}}{{pass}}"
placeholder="yyyy-mm-dd" title="yyyy-mm-dd" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}"> placeholder="yyyy-mm-dd" title="yyyy-mm-dd" pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))">
</div> </div>
<div class="field_div"> <div class="field_div">
<label for="run_info_{{=i}}" id="run_info__label_{{=i}}">Info:</label> <label for="run_info_{{=i}}" id="run_info__label_{{=i}}">Info:</label>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment