Cart Licenses Contact Support Online Creator Login/Register
Try
Free
v 1.9.29

Text

Single line text - Text question


                        
        
            Survey.StylesManager.applyTheme("modern");
        



                
                    var json = {
  "elements": [
    {
      "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(sender) {
            document.querySelector('#surveyResult').textContent =
            "Result JSON:\n" + JSON.stringify(sender.data, null, 3);
            });
        
        
            $("#surveyElement").Survey({
            model: survey 
            });
        

                    
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Text, 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-core/modern.min.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:

settings

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