<!DOCTYPE html>
<html>
<head>
<title>Standard validators for plaform jQuery, SurveyJS Library Example</title>
<script src="https://unpkg.com/jquery"></script>
<script src="https://surveyjs.azureedge.net/0.12.35/survey.jquery.js"></script>
<link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div id="surveyElement">
</div>
<div id="surveyResult"></div>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>
Survey.Survey.cssType = "bootstrap";
Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
window.survey = new Survey.Model({
questions: [
{ type: "text", name: "socialid", title: "Please enter your social security number", isRequired: true,
validators: [{type:"regex", regex:"^[0-9]{3}\-?[0-9]{2}\-?[0-9]{4}$",
text: "Please enter a valid social security number"
}]}
]});
survey.onComplete.add(function(result) {
document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
});
$("#surveyElement").Survey({
model: survey
});
.btn-green {
background-color: #1ab394;
color: #fff;
border-radius: 3px;
}
.btn-green:hover, .btn-green:focus {
background-color: #18a689;
color: #fff;
}
.panel-footer {
padding: 0 15px;
border:none;
text-align: right;
background-color: #fff;
}