To do a validation using jquery.form.js

2011-05-28  来源:本站原创  分类:Web  人气:105 

These days of jquery's form plugin. Posted examples of his own record to do, my memory is not particularly good!

Post code first:

Form does not post some more, broadly speaking, are you, most of all the file boxes (text), which has a 4 single box (radio), and a submit.

This validation also some problems in the submission of the time, although prompted to be empty, but still submitted to success, that return false and can not stop the form submission. Later in the online help, to find a solution to return false replaced $ ('# add'). PreventDefault (); on it
preventDefault () This function, which means that the default submit action to prevent

$(function(){
        $('#add').ajaxForm({
                beforeSubmit:checkForm,// Before submitting
                success:complate,// After a successful submission
                dataType:'json'// Data format
        });

        function checkForm(){
                        $('input').each(function (index,arr){// Select all of the input label , And cycling
                                if($(this).attr('type') == 'text'){// If the type is text, that text box
                                        if($(this).val() == ''){// Whether the view is empty
                                                $(this).focus();// Locating focus
                                                $('#error').html(' Cannot be empty ');// Tip
                                                $('#add').preventDefault();// Prevent form submit
                                        }
                                }
                        });
                        $('input:gt(6)').each(function (n,v){
                                var ck = /^\d*$/;// Verification of pure digital is the
      /*gt(6) It meant the sixth from the selection of all elements of the input label , Contrary to the lt(6); Is to select all elements prior to the sixth element of. Note that the start is required to 0 To begin, as with arrays , The first element is 0!*/

                                if($(this).val() != '' && $(this).attr('type') == 'text'){// Is not null and is a text box, because the last is a submit
                                        if(!ck.test($(this).val())){// Regular validation
                                                $(this).focus();// Focus
                                                $('#error').html(' Please enter a number ');      // Tip
                                                $('#add').preventDefault();// Prevent form submit
                                        }
                                }
                        });                     

        }
        // Below are some tips for validation after the success of information
        function complate(data){
                if(data.status == 1){
                        $('#sub').attr('disabled',true);// Disable button to prevent duplicate submissions
                        $('#error').html(data.info);
                        //alert(' A successful submission ');
                }
                else{
                        $('#error').html(data.info);
                }
        }
});
相关文章
  • To do a validation using jquery.form.js 2011-05-28

    These days of jquery's form plugin. Posted examples of his own record to do, my memory is not particularly good! Post code first: Form does not post some more, broadly speaking, are you, most of all the file boxes (text), which has a 4 single box (ra

  • jquery.form.js application entry 2010-09-18

    Here Jquery form validation plugin jquery.form.js framework application, first download the necessary JS files jquery.form.rar jquery.rar Started the following: A simple plug-entry Form The first step: the first to add a table form action="comment.ph

  • ActiveRecord objects with the use of jQuery to create jquery.form.js 2009-09-26

    ActiveRecord objects with the use of jQuery to create jquery.form.js Part of the code, the original look http://malsup.com/jquery/form/ # getting-started // prepare the form when the DOM is ready $(document).ready(function() { var options = { target:

  • jquery.form.js ajax upload file problem 2010-07-20

    Question: Use jquery.form.js achieve ajax upload function, when the server returned json string format, and header information is application / json, the client code to success callback function can not be implemented. Reason: As jquery.form.js ajax

  • jquery.form.js conflict with document.domain 2010-07-20

    jquery.form.js the ajaxForm, ajaxSubmit method can not be successful implementation of the callback function: 1. Using response.getWriter (). Out () print data to the client <script type="text/javascript"> document.domain = "XXX.com&q

  • 解决3.01版的jquery.form.js中文乱码问题的解决方法 2013-11-30

    最近用到了jquery的一个fom插件,是一个全面支持表单的jQuery插件.昨天在用ajaxSubmit进行Form Post提交的时候,发现服务器端取回的中文数据居然是乱码.这个可能是因为jquery是utf-8,不支持gb2312 网上搜了很多方法,可能因为我用的这jquery.form.js是3.01版,也就是今年3月6日才发布的版本(汗...就是前天),所以普遍不太管用.至于低版本的是否管用,这个我没有去考证,但大部分还是不负责任的Copy Copy Copy .还有一些方法是在提交前

  • jquery.form.js用法之清空form的方法 2013-12-11

    这篇文章主要介绍了jquery.form.js清空form的方法,需要的朋友可以参考下 本段代码摘取自jquery.form.js中,由于觉得该方法的使用性非常强,同时也可独立拿出来使用. 该段代码言简意赅可以很好的作为学习参考. /** * Clears the form data. Takes the following actions on the form's input fields: * - input text fields will have their 'value' prop

  • jquery.form.js实现将form提交转为ajax方式提交的方法 2015-02-10

    这篇文章主要介绍了jquery.form.js实现将form提交转为ajax方式提交的方法,涉及jQuery插件实现form表单的Ajax提交技巧,非常具有实用价值,需要的朋友可以参考下 本文实例讲述了jquery.form.js实现将form提交转为ajax方式提交的方法.分享给大家供大家参考.具体分析如下: 这个框架集合form提交.验证.上传的功能. 这个框架必须和jquery完整版结合,否则使用min则无效. 原理:利用js进行对form进行组装成ajax的url和data,原理还是用a

  • jquery表单验证插件 jquery.form.js 2012-05-08

    Form插件,支持Ajax,支持Ajax文件上传,功能强大,基本满足日常应用. 1.JQuery框架软件包下载 http://docs.jquery.com/Downloading_jQuery 2.Form插件下载 https://github.com/malsup/form/blob/master/jquery.form.js 3.Form插件的简单入门 第一步:先增加一个表单 <form id="myForm" action="comment.php"

  • 关于jquery.form.js插件的无刷新上传文件使用的问题 2012-12-12

    (一)如何使用:它的文件无刷新上传写法跟jquery的ajax差不多,也不多说了,看下面代码估计就知道了,注意设置表单属性enctype="multipart/form-data" (二)遇到问题:ASP.NET MVC中返回JsonResult对象时,IE8提示下载文件 (1)看我是如何操作的:利用如下代码无刷新上传文件 var options = { target: '#outputdiv', beforeSubmit: showRequest, success: function

  • jQuery表单插件jquery.form.js 2015-01-25

    概述 jQuery Form Plugin能够让你简洁的将以HTML形式提交的表单升级成采用AJAX技术提交的表单. 插件里面主要的方法, ajaxForm和ajaxSubmit,能够从form组件里采集信息确定如何处理表单的提交过程. 两个方法都支持众多的可选参数,能够让你对表单里数据的提交做到完全的控制. 入门指导 一.在你的页面里写一个表单.一个普通的表单,不需要任何特殊的标记: <form id="myForm" action="login.action&quo

  • 使用jquery.form.js 提交表单 2015-05-01

    //jquery.form.js 序列化表单的数据 //提交表单 $("#allorder_to_add").click(function(){ var params=$("#allorder-detail-add").formSerialize(); //这里直接就序列化了表单里面的值 params = decodeURIComponent(params,true); return; $.ajax({ type:"POST",// 指定是pos

  • jquery.form.js官方插件介绍Form插件,支持Ajax,支持Ajax文件上传 2011-12-14

    [JQuery框架应用]:form.js官方插件介绍 Form插件,支持Ajax,支持Ajax文件上传,功能强大,基本满足日常应用. 1.JQuery框架软件包下载 文件: jquery.rar 大小: 29KB 下载: 下载 2.Form插件下载 文件: jquery.form.rar 大小: 7KB 下载: 下载 3.Form插件的简单入门 第一步:先增加一个表单 <form id="myForm" action="comment.php" method=

  • jquery表单插件 jquery.form.js 2012-09-07

    Form插件,支持Ajax,支持Ajax文件上传,功能强大,基本满足日常应用. 1.JQuery框架软件包下载 文件: jquery.rar 大小: 29KB 下载: 下载 2.Form插件下载 文件: jquery.form.rar 大小: 7KB 下载: 下载 3.Form插件的简单入门 第一步:先增加一个表单 <form id="myForm" action="comment.php" method="post"> Name:

  • jquery.form.js plug-in usage of some functions 2010-07-19

    English original: http://www.malsup.com/jquery/form/ # API Form Plugin API provides several methods , Form allows you to easily manage data and form submission . ajaxForm Increase in all the required event listeners for the AJAX Ready to submit the f

  • jquery.validate.js IE do not pass under the validation date 2010-11-08

    Form validation using jquery.validate.js date format, date verified in the next Firefox, ie not by the next. Reference http://geekswithblogs.net/EltonStoneman/archive/2009/10/29/jquery-date-validation-in-chrome.aspx , problem solving

  • jQuery.Form plug-in description 2010-04-07

    I. Introduction jQuery From Ajax plug-ins is an excellent form plugin allows you to use it very easy, non-invasive way to upgrade HTML forms to support Ajax. jQuery From There are two main ways: ajaxForm and ajaxSubmit, which brings together elements

  • jquery validate.js x learning 2010-04-12

    Learning the jquery validate.js this is jquery plug-ins, I think Mody, used jquery to change the habit of many of our programming, we are accustomed to traditional authentication methods, the validation js pages written form, or extracted , written i

  • jquery.validate.js IE is not verified by the next date 2010-11-08

    Form validation using jquery.validate.js date format, date verified in the next Firefox, ie not by the next. Reference http://geekswithblogs.net/EltonStoneman/archive/2009/10/29/jquery-date-validation-in-chrome.aspx , problem solving

  • jQuery Form Plugin (a): Form to submit a form using AJAX 2011-01-06

    JQuery Form plug-in allows you to easily use AJAX to submit Form form, the main method and ajaxSubmit ajaxForm form elements responsible for the collection of information, management submitted to the process. Both are configurable, giving you ultimat