Survey.StylesManager.applyTheme("modern");
var json = { questions: [
{name:"name", type:"text", title: "Please enter your name:", placeHolder:"Jon Snow", isRequired: true, autoComplete: "name"},
{name:"birthdate", type:"text", inputType:"date", title: "Your birthdate:", isRequired: true, autoComplete: "bdate"},
{name:"color", type:"text", inputType:"color", title: "Your favorite color:"},
{name:"email", type:"text", inputType:"email", title: "Your e-mail:", placeHolder:"jon.snow@nightwatch.org", isRequired: true, autoComplete: "email", validators: [{type:"email"}]}
]};
window.survey = new Survey.Model(json);
survey.onComplete.add(function(result) {
document.querySelector('#surveyResult').textContent =
"Result JSON:\n" + JSON.stringify(result.data, null, 3);
});
$("#surveyElement").Survey({
model: survey
});
<!DOCTYPE html>
<html lang="en">
<head>
<title>Single line text - Text question, jQuery Survey Library Example</title>
<meta name="viewport" content="width=device-width" />
<script src="https://unpkg.com/jquery"></script>
<script src="/DevBuilds/survey-jquery/survey.jquery.min.js"></script>
<link href="/DevBuilds/survey-knockout/modern.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div id="surveyElement" style="display:inline-block;width:100%;">
</div>
<div id="surveyResult"></div>
<script type="text/javascript" src="./index.js"></script>
</body>
</html>
We are using HTML5 input type for this functionality. Please note, that some browsers do not support it. Here is the matrix of how browsers support HTML5 input type.
Here you cand find solutions with using third-party sripts: