EasyUI Forum
May 15, 2024, 04:56:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Turn off Autocomplete after Form Post  (Read 9902 times)
mcenal
Newbie
*
Posts: 10


View Profile
« on: May 01, 2014, 09:12:21 AM »

I'm writing a tool application where people fill in forms for Purchase orders and timesheets.  My forms all work via the ajax calls and using jquery exclusively from the documentation and tutorials.  My problem is however when someone clicks in a number field in the PO after the form was posted once, it automatically autocompletes that number field when autocomplete makes no logical sense there.  Is there a way to turn this off?  I've already tried autocomplete="off" in the input html which didn't work and I tried some javascript that was supposed to do the same, also to no avail.  (http://css-tricks.com/snippets/html/autocomplete-off/)  This tag for inputs is supposedly HTML5 standard but both Chrome and IE seem to be ignoring it.

Code:
<html>
    <head>
    <meta charset="UTF-8">
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="cache" />
    <title>Edit Project</title>
    <link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="themes/icon.css">
    <link rel="stylesheet" type="text/css" href="demo.css">
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.easyui.min.js"></script>
    </head>
    <body>
<form id="ff" method="post" autocompete="off" >
Quantity:
    <input class="easyui-numberbox"  type="edit"  name="quantity" value="" style="width:145px;"  data-options="min:0,precision:2" id="quantity" autocomplete="off"/>
</form>
 <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
<script>
 function submitForm(){

var url = 'tested.php';
jqxhr = $.ajax({
type: "POST",
dataType: "json",
url : url,
data: $("#ff").serialize()
});

jqxhr.always(function(){
$('#dg').datagrid('reload');
$(':input','#ff')
.not(':button, :submit, :reset, :hidden')
.val('');
});
 }
</script>
</body>
</html>

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 01, 2014, 05:12:16 PM »

To clear a form fields, please call 'clear' method instead.
Code:
$('#ff').form('clear');

Or call the numberbox's 'clear' method to clear its field value.
Code:
$('#quantity').numberbox('clear');
Logged
mcenal
Newbie
*
Posts: 10


View Profile
« Reply #2 on: May 02, 2014, 09:22:49 AM »

To clear a form fields, please call 'clear' method instead.
Code:
$('#ff').form('clear');

Can I still specify which fields to ignore and still call this command? For example clearing all fields except hidden ones.  I know if I have to I can just call multiple times the other codefield, but I like the ability to select partials to keep the code footprint smaller.
Logged
mcenal
Newbie
*
Posts: 10


View Profile
« Reply #3 on: May 02, 2014, 02:12:38 PM »

Well no matter it is a minor issue anyway.  I've just decided to use the second command and run it for each option as they come up.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!