Skip to content

Commit 7c8b0b4

Browse files
committed
Merge pull request #119 from vsoch/validation_update
Validation update
2 parents 76ad89a + 004eeee commit 7c8b0b4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

expfactory/survey.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def create_checkbox(text,id_attribute,options,classes="",required=0):
130130
checkbox_html = '<p id="%s_options">%s</p>' %(id_attribute,text)
131131
for n in range(len(options)):
132132
option_id = "%s_%s" %(id_attribute,n)
133-
checkbox_html = '%s\n<label class="%s" for="checkbox-%s">\n<input type="checkbox" id="checkbox-%s" %s class="mdl-checkbox__input %s %s" name="%s_options" value="%s">\n<span class="mdl-checkbox__label">%s</span>\n</label>' %(checkbox_html,class_names,option_id,option_id,meta,classes,required,id_attribute,options[n],options[n])
133+
checkbox_html = '%s\n<label class="%s" for="checkbox-%s">\n<input type="checkbox" id="checkbox-%s" %s class="mdl-checkbox__input %s %s" name="%s_options" value="%s">\n<span class="mdl-checkbox__label">%s</span>\n</label>' %(checkbox_html,class_names,option_id,option_id,meta,classes,required,option_id,options[n],options[n])
134134
return "%s<br><br><br>" %(checkbox_html)
135135

136136
def base_textfield(text,id_attribute,box_text=None):
@@ -313,9 +313,10 @@ def parse_validation(required_counts):
313313
validation = "%s if ( state.stepIndex === %s ) {\n" %(validation,page_number)
314314
else:
315315
validation = "%s else if ( state.stepIndex === %s ) {\n" %(validation,page_number)
316-
validation = "%s if (($.unique($('.page%s.required[type=number],.page3.required:text').map(function(){return this.name})).map(function() {return $('[name*=' + this + '].required[type=number], [name*=' + this + '].required:text').filter(function() { return $(this).val();}).length > 0}).get().indexOf(false) != -1) || ($.unique($('.page%s.required:not([type=number]):not(:text)').map(function(){return this.name})).map(function() {return $('[name*=' + this + '].required:checked').length > 0}).get().indexOf(false) != -1)){\nis_required($('.page%s.required:not(checked)'));\nreturn false;\n" % (validation, page_number, page_number, page_number)
316+
validation = '%s if (($.unique($(`.page%s.required[type=number],.page%s.required:text`).map(function(){return $(this).attr(`meta-text`)})).map(function() {return $(`[meta-text*="` + this + `"].required[type=number], [meta-text*="` + this + `"].required:text`).filter(function() { return $(this).val();}).length > 0}).get().indexOf(false) != -1) || ($.unique($(`.page%s.required:not([type=number]):not(:text)`).map(function(){return $(this).attr(`meta-text`)})).map(function() {return $(`[meta-text*="` + this + `"].required:checked`).length > 0}).get().indexOf(false) != -1)){\nis_required($(`.page%s.required:not(checked)`));\nreturn false;\n' % (validation, page_number, page_number, page_number, page_number)
317317

318318

319+
319320
# If we are at the last page, passing validation should enable the submit
320321
if page_number == pages[-1]:
321322
validation = '%s } else {\nexpfactory_finished=true;\n' %(validation)

0 commit comments

Comments
 (0)