Single line text - Text question


var json =  { questions: [
     {name:"name", type:"text", title: "Please enter your name:", placeHolder:"Jon Snow", isRequired: true},
     {name:"birthdate", type:"text", inputType:"date", title: "Your birthdate:", isRequired: true},
     {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, validators: [{type:"email"}]}

window.survey = new Survey.Model(json);

survey.onComplete.add(function(result) {
    document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);

    model: survey 

<!DOCTYPE html>
    <title>Single line text - Text question, jQuery Survey Library Example</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/jquery"></script>
<script src="https://surveyjs.azureedge.net/1.0.33/survey.jquery.js"></script>
<link href="https://surveyjs.azureedge.net/1.0.33/survey.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="./index.css">

                <div id="surveyElement">
    <div id="surveyResult"></div>

<script type="text/javascript" src="./index.js"></script>


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:

By default the input type is "text" (inputType="text"). The following additional input types are available:

  • color
  • date
  • datetime
  • datetime-local
  • email
  • month
  • number
  • password
  • range
  • tel
  • text
  • time
  • url
  • week