Autofill

未知
未知
2008-09-19

This plugin offers the ability to auto fill form.

If the first parameter is an URL, the plugin will fetch the returned JSON object via AJAX. Or you can pass a pre-fetched JSON object so that no AJAX will be performed.

The second parameter is an object containing other options.

  • type - AJAX request type

  • data - Data to be sent to the server

  • errorTrigger - if the JSON object contains this as its key, error callback will be triggered. Useful if server side returns a custom error message

  • mSelectCheckName - Default to false.
    True:  look for multiple select boxes with their name.
    False: look for multiple select boxes with their ID

  • ajaxError - callback function for AJAX error

  • error - error callback if the JSON object is empty, or contains errorTrigger as its key

  • beforeFillForm - callback function to be executed before start filling the form

  • beforeFill - callback function to be executed BEFORE filling a form element

  • afterFill - callback function to be executed AFTER filling a form element

  • complete - callback function to be executed when all form elements have been filled

Basi Example with pre-fetched data

var data = { username: 'peter', gender: 'M' };
$('form').autoFill(data);

Full Example using AJAX:

$('form').autoFill('get_data.php',
{
    type: 'GET', // AJAX request method
   
    data: { record_id: 2 }, // Request parameters

    // if the JSON object contains this key,
    // error callback will be triggered.
    // Useful if server side returns a custom error message
    errorTrigger: 'error',

    // Default to false.
    // True:  look for multiple select boxes with their name
    // False: look for multiple select boxes with their ID
    mSelectCheckName: false,
   
    ajaxError: function(error, form)
    {
        // do something if AJAX error occurs
        alert(error);
        $(form).hide();
    },
    error: function(form)
    {
        // do something if error occurs
        alert('Unable to fill form!');
        $(form).hide();
    },
    beforeFillForm: function(form)
    {
        // do something before start filling the form
        $(form).show();
    },
    beforeFill: function(key, value, form)
    {
        // do something BEFORE filling an element
       
        if(key == 'password')
            return false; // return false to skip current form element

        if(key == 'gender' && value == 'female')
            alert("OH! She's a lady!");
    },
    afterFill: function(key, value, form)
    {
        // do something AFTER filling an element
        if(value == 'blah')
            confirm('What are you talking about?');

        if(key == 'zip' && value == '')
            return false; // return false to skip all pending form elements
    },
    complete: function(processed, form)
    {
        // do something when all elements have been filled
        alert(processed + ' elements have been filled!');
    }
});

加载中

评论(0)

暂无评论

暂无资讯

暂无问答

谷歌浏览器输入框背景颜色变黄的解决方案

input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus { box-shadow:0 0 0 60px #eee inset; -webkit-text-fill-color: #878787; }......

2018/11/30 20:43
20
0
Android 8.1 cause crash to EditText

https://stackoverflow.com/questions/47763756/autofill-framework-updates-8-1-cause-crash-to-edittext down vote I had similiar problem. Same error when tapping on EditText, of fie...

2018/07/30 09:43
23
0
chrome表单自动填充导致input文本框背景变成偏黄色问题解决

chrome表单自动填充后,input文本框的背景会变成偏黄色的,想必大家都会碰到这种情况吧,这是由于chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性造成的,解决方法如下...

2014/08/07 14:09
541
0
chrome表单自动填充去掉input黄色背景解决方案

chrome表单自动填充后,input文本框的背景会变成偏黄色的,这是由于chrome会默认给自动填充的input表单加上input:-webkit- autofill私有属性,然后对其赋予以下样式: input:-webkit-autofi...

2016/10/11 10:31
76
0
css修改placeholder兼容浏览器内核的颜色

一、多数编辑器都提供了这几种 方法 啪啪敲出内核首字母 便会有提示 ::-webkit-input-placeholder{ } :-moz-placeholder{ } ::-moz-placeholder{ } :-ms-input-placeholder{ } 二、另外再附上...

2016/11/06 16:42
11
0
input 坑

设置input placeholder样式; input::-webkit-input-placeholder { color: #999999; opacity: 1; } 消去input的黄色样式 input[type="text"]:-webkit-autofill { -webkit-text-fill-color: #...

2018/01/12 15:26
3
0
input浏览器默认填充样式

/*默认样式*/ input:-webkit-autofill { background-color: #FAFFBD; background-image: none; color: #000; } /*修改*/ input:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px red ...

2016/07/01 11:23
44
0
chrome表单自动填充去掉input黄色背景解决方案

chrome表单自动填充后,input文本框的背景会变成偏黄色的,

2015/11/08 22:48
132
0
禁用chrome表单自动填充

if ($.browser.webkit) {     $('input[name="password"]').attr('autocomplete', 'off');     $('input[name="email"]').attr('autocomplete', 'off'); } $(document).ready(f...

2014/09/11 23:15
100
0
Swift中viewWeb执行JS

``` // 自动填充 - webVIew的注入,直接通过js修改 本地浏览器中 缓存的页面内容 // 让webView执行js @objc private func autoFill(){ // 准备js let js = "document.getElementById('userI...

2016/09/17 22:07
0
0

没有更多内容

加载失败,请刷新页面

返回顶部
顶部