Android - text inputs are not verified with a custom validation plugin

I am working on this plugin and I have an error message that talks about some issues with Android 2.3.

I downloaded the Android SDK and tried the plugin in version 2.3, and it looks like the text inputs are not checked, and the error does not appear or does not work. Other entrances confirm the penalty. I tried in Android 4.0+ and it seems to work fine. I don’t know where to start, because I don’t know where this problem is from, and I don’t have a real Android phone to debug these things, and the emulator lacks development tools, etc.

I doubt that dumping the code here will help, but this is the method validate()that can be found in js/idealforms.js. An “error” should appear either here or somewhere else in this file, unless it is CSS related, which I don’t think so.

/** Validates an input
 * @memberOf Actions
 * @param {object} input Object that contains the jQuery input object [input.input]
 * and the user options of that input [input.userOptions]
 * @param {string} value The value of the given input
 * @returns {object} Returns [isValid] plus [error] if it fails
 */
validate: function (input, value) {

  var isValid = true,
      error = '',
      $input = input.input,
      userOptions = input.userOptions,
      userFilters = userOptions.filters

  if (userFilters) {

    // Required
    if (!value && /required/.test(userFilters)) {
      error = (
        userOptions.errors && userOptions.errors.required
          ? userOptions.errors.required
          : 'This field is required.'
      )
      isValid = false
    }

    // All other filters
    if (value) {
      userFilters = userFilters.split(/\s/)
      for (var i = 0, len = userFilters.length; i < len; i++) {
        var uf = userFilters[i],
            theFilter = typeof Filters[uf] === 'undefined' ? '' : Filters[uf],
            isFunction = typeof theFilter.regex === 'function',
            isRegex = theFilter.regex instanceof RegExp
        if (
          theFilter && (
            isFunction && !theFilter.regex(input, value) ||
            isRegex && !theFilter.regex.test(value)
          )
        ) {
          isValid = false
          error = (
            userOptions.errors && userOptions.errors[uf] ||
            theFilter.error
          )
          break
        }
      }
    }

  }

  return {
    isValid: isValid,
    error: error
  }
}

Can anyone help me out? I want this plugin to work as many platforms as possible, but it is difficult to do without an actual Android phone.

+5
source share
1 answer

Is this the current code?

I can’t point out anything specific that might cause your problem, but sometimes these types of errors are triggered by quirks in a specific version of the browser, so I would check a little:

(1) , "" Javascript, , - ( - ), . .

(2) , Filters:

        theFilter = typeof Filters[uf] === 'undefined' ? '' : Filters[uf],

userFilters... is Filters , ?

(3) :

$input = input.input,

$input? .

(4) && || :

if (
      theFilter && (
        isFunction && !theFilter.regex(input, value) ||
        isRegex && !theFilter.regex.test(value)
      )
    )

  error = (
    userOptions.errors && userOptions.errors[uf] ||
    theFilter.error
  )

, .

+1

All Articles