Skip to content

Refactor input check for quesitonnaire input -- use html5 inline instead #384

@peterkos

Description

@peterkos

Can just use HTML 5 input attribute pattern type thing instead of regex

Note that this should really just modify this section of app/assets/javascripts/validate.js

case 'email':
if (value) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!re.test(value)) {
notify(this, 'Invalid Email');
success = false;
}
}
break;
case 'phone':
if (value) {
var phoneReg = /^[\+]?[0-9]{0,3}[-\s\.]?[(]?[0-9]{1,3}[)]?[-\s\.]?[0-9]{1,3}[-\s\.]?[0-9]{4,6}$/;
if (!phoneReg.test(value)) {
notify(this, 'Please enter a valid phone number');
success = false;
}
}
break;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions