Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-15893

Client side HTML5 validation fails partially

    XMLWordPrintable

Details

    • Unknown

    Description

      I'm trying to amend server-side validation with HTML5 client-side validation. I ask the field for its regular expression and use it as a pattern for the input element:

      #set($class = 'App.Bibitem.Code.BibitemClass')
      #set ($xclass = $xwiki.getDocument($class).xWikiClass)
      #set ($discard = $doc.use($class))
      (% class="xform" %)(((
        #if ($xcontext.action == 'edit')
          <input type="hidden" name="xvalidate" value="1" />
          #set($field = "bib_o_label")
          #set ($definition = $xclass.get($field))
          ; <label for="${class}_0_${field}">$escapetool.xml($doc.displayPrettyName($field))</label>
          #set ($regexp = $definition.getValue('validationRegExp').substring(1))
          #set ($length = $regexp.length() - 1)
          #set ($regexp = $regexp.substring(0, $length))
          #set ($value = $doc.display($field, 'view'))
          : <input id="${class}_0_${field}" name="${class}_0_${field}" size="30" type="text" value="$value" required pattern="$regexp">
          ...
      

      With XWiki 10.7 I see the following behavior when editing a page with a wrong input:

      When pressing the Preview button, the page stays in edit mode and displays a tooltip "Please match the requested format.". Fine. That what I would expect.

      When pressing the Save button, the page stays in edit mode and displays a bottom line error "Failed to save the page. Reason: Server not responding".

      When pressing Save & View a freshly created page turns grey and displays the bottom line message "Saving... 0%" forever. Bad. A modified page stays in edit mode and displays a tooltip "Please match the requested format.". Fine.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Kido Guido Kracke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: