Search Results

Search found 316 results on 13 pages for 'blur'.

Page 8/13 | < Previous Page | 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How do I clip an image in OpenGL ES on Android?

    - by Maxim Shoustin
    My game involves "wiping off" an image by touch: After moving a finger over it, it looks like this: At the moment, I'm implementing it with Canvas, like this: 9Paint pTouch; 9int X = 100; 9int Y = 100; 9Bitmap overlay; 9Canvas c2; 9Rect dest; pTouch = new Paint(Paint.ANTI_ALIAS_FLAG); pTouch.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT)); pTouch.setColor(Color.TRANSPARENT); pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL)); overlay = BitmapFactory.decodeResource(getResources(),R.drawable.wraith_spell).copy(Config.ARGB_8888, true); c2 = new Canvas(overlay); dest = new Rect(0, 0, getWidth(), getHeight()); Paint paint = new Paint();9 paint.setFilterBitmap(true); ... @Override protected void onDraw(Canvas canvas) { ... c2.drawCircle(X, Y, 80, pTouch); canvas.drawBitmap(overlay, 0, 0, null); ... } @Override 9public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: { X = (int) event.getX(); Y = (int) event.getY();9 invalidate(); c2.drawCircle(X, Y, 80, pTouch);9 break; } } return true; ... What I'm essentially doing is drawing transparency onto the canvas, over the red ball image. Canvas and Bitmap feel old... Surely there is a way to do something similar with OpenGL ES. What is it called? How do I use it? [EDIT] I found that if I draw an image and above new image with alpha 0, it goes to be transparent, maybe that direction? Something like: gl.glColor4f(0.0f, 0.0f, 0.0f, 0.01f);

    Read the article

  • jQuery - Why editable-select list plugin doesn't work with latest jQuery?

    - by Binyamin
    Why editable-select list plugin<select><option>value</option>doesn't work with latest jQuery? editable-select code: /** * Copyright (c) 2009 Anders Ekdahl (http://coffeescripter.com/) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Version: 1.3.1 * * Demo and documentation: http://coffeescripter.com/code/editable-select/ */ (function($) { var instances = []; $.fn.editableSelect = function(options) { var defaults = { bg_iframe: false, onSelect: false, items_then_scroll: 10, case_sensitive: false }; var settings = $.extend(defaults, options); // Only do bg_iframe for browsers that need it if(settings.bg_iframe && !$.browser.msie) { settings.bg_iframe = false; }; var instance = false; $(this).each(function() { var i = instances.length; if(typeof $(this).data('editable-selecter') == 'undefined') { instances[i] = new EditableSelect(this, settings); $(this).data('editable-selecter', i); }; }); return $(this); }; $.fn.editableSelectInstances = function() { var ret = []; $(this).each(function() { if(typeof $(this).data('editable-selecter') != 'undefined') { ret[ret.length] = instances[$(this).data('editable-selecter')]; }; }); return ret; }; var EditableSelect = function(select, settings) { this.init(select, settings); }; EditableSelect.prototype = { settings: false, text: false, select: false, wrapper: false, list_item_height: 20, list_height: 0, list_is_visible: false, hide_on_blur_timeout: false, bg_iframe: false, current_value: '', init: function(select, settings) { this.settings = settings; this.select = $(select); this.text = $('<input type="text">'); this.text.attr('name', this.select.attr('name')); this.text.data('editable-selecter', this.select.data('editable-selecter')); // Because we don't want the value of the select when the form // is submitted this.select.attr('disabled', 'disabled'); var id = this.select.attr('id'); if(!id) { id = 'editable-select'+ instances.length; }; this.text.attr('id', id); this.text.attr('autocomplete', 'off'); this.text.addClass('editable-select'); this.select.attr('id', id +'_hidden_select'); this.initInputEvents(this.text); this.duplicateOptions(); this.positionElements(); this.setWidths(); if(this.settings.bg_iframe) { this.createBackgroundIframe(); }; }, duplicateOptions: function() { var context = this; var wrapper = $(document.createElement('div')); wrapper.addClass('editable-select-options'); var option_list = $(document.createElement('ul')); wrapper.append(option_list); var options = this.select.find('option'); options.each(function() { if($(this).attr('selected')) { context.text.val($(this).val()); context.current_value = $(this).val(); }; var li = $('<li>'+ $(this).val() +'</li>'); context.initListItemEvents(li); option_list.append(li); }); this.wrapper = wrapper; this.checkScroll(); }, checkScroll: function() { var options = this.wrapper.find('li'); if(options.length > this.settings.items_then_scroll) { this.list_height = this.list_item_height * this.settings.items_then_scroll; this.wrapper.css('height', this.list_height +'px'); this.wrapper.css('overflow', 'auto'); } else { this.wrapper.css('height', 'auto'); this.wrapper.css('overflow', 'visible'); }; }, addOption: function(value) { var li = $('<li>'+ value +'</li>'); var option = $('<option>'+ value +'</option>'); this.select.append(option); this.initListItemEvents(li); this.wrapper.find('ul').append(li); this.setWidths(); this.checkScroll(); }, initInputEvents: function(text) { var context = this; var timer = false; $(document.body).click( function() { context.clearSelectedListItem(); context.hideList(); } ); text.focus( function() { // Can't use the blur event to hide the list, because the blur event // is fired in some browsers when you scroll the list context.showList(); context.highlightSelected(); } ).click( function(e) { e.stopPropagation(); context.showList(); context.highlightSelected(); } ).keydown( // Capture key events so the user can navigate through the list function(e) { switch(e.keyCode) { // Down case 40: if(!context.listIsVisible()) { context.showList(); context.highlightSelected(); } else { e.preventDefault(); context.selectNewListItem('down'); }; break; // Up case 38: e.preventDefault(); context.selectNewListItem('up'); break; // Tab case 9: context.pickListItem(context.selectedListItem()); break; // Esc case 27: e.preventDefault(); context.hideList(); return false; break; // Enter, prevent form submission case 13: e.preventDefault(); context.pickListItem(context.selectedListItem()); return false; }; } ).keyup( function(e) { // Prevent lots of calls if it's a fast typer if(timer !== false) { clearTimeout(timer); timer = false; }; timer = setTimeout( function() { // If the user types in a value, select it if it's in the list if(context.text.val() != context.current_value) { context.current_value = context.text.val(); context.highlightSelected(); }; }, 200 ); } ).keypress( function(e) { if(e.keyCode == 13) { // Enter, prevent form submission e.preventDefault(); return false; }; } ); }, initListItemEvents: function(list_item) { var context = this; list_item.mouseover( function() { context.clearSelectedListItem(); context.selectListItem(list_item); } ).mousedown( // Needs to be mousedown and not click, since the inputs blur events // fires before the list items click event function(e) { e.stopPropagation(); context.pickListItem(context.selectedListItem()); } ); }, selectNewListItem: function(direction) { var li = this.selectedListItem(); if(!li.length) { li = this.selectFirstListItem(); }; if(direction == 'down') { var sib = li.next(); } else { var sib = li.prev(); }; if(sib.length) { this.selectListItem(sib); this.scrollToListItem(sib); this.unselectListItem(li); }; }, selectListItem: function(list_item) { this.clearSelectedListItem(); list_item.addClass('selected'); }, selectFirstListItem: function() { this.clearSelectedListItem(); var first = this.wrapper.find('li:first'); first.addClass('selected'); return first; }, unselectListItem: function(list_item) { list_item.removeClass('selected'); }, selectedListItem: function() { return this.wrapper.find('li.selected'); }, clearSelectedListItem: function() { this.wrapper.find('li.selected').removeClass('selected'); }, pickListItem: function(list_item) { if(list_item.length) { this.text.val(list_item.text()); this.current_value = this.text.val(); }; if(typeof this.settings.onSelect == 'function') { this.settings.onSelect.call(this, list_item); }; this.hideList(); }, listIsVisible: function() { return this.list_is_visible; }, showList: function() { this.wrapper.show(); this.hideOtherLists(); this.list_is_visible = true; if(this.settings.bg_iframe) { this.bg_iframe.show(); }; }, highlightSelected: function() { var context = this; var current_value = this.text.val(); if(current_value.length < 0) { if(highlight_first) { this.selectFirstListItem(); }; return; }; if(!context.settings.case_sensitive) { current_value = current_value.toLowerCase(); }; var best_candiate = false; var value_found = false; var list_items = this.wrapper.find('li'); list_items.each( function() { if(!value_found) { var text = $(this).text(); if(!context.settings.case_sensitive) { text = text.toLowerCase(); }; if(text == current_value) { value_found = true; context.clearSelectedListItem(); context.selectListItem($(this)); context.scrollToListItem($(this)); return false; } else if(text.indexOf(current_value) === 0 && !best_candiate) { // Can't do return false here, since we still need to iterate over // all list items to see if there is an exact match best_candiate = $(this); }; }; } ); if(best_candiate && !value_found) { context.clearSelectedListItem(); context.selectListItem(best_candiate); context.scrollToListItem(best_candiate); } else if(!best_candiate && !value_found) { this.selectFirstListItem(); }; }, scrollToListItem: function(list_item) { if(this.list_height) { this.wrapper.scrollTop(list_item[0].offsetTop - (this.list_height / 2)); }; }, hideList: function() { this.wrapper.hide(); this.list_is_visible = false; if(this.settings.bg_iframe) { this.bg_iframe.hide(); }; }, hideOtherLists: function() { for(var i = 0; i < instances.length; i++) { if(i != this.select.data('editable-selecter')) { instances[i].hideList(); }; }; }, positionElements: function() { var offset = this.select.offset(); offset.top += this.select[0].offsetHeight; this.select.after(this.text); this.select.hide(); this.wrapper.css({top: offset.top +'px', left: offset.left +'px'}); $(document.body).append(this.wrapper); // Need to do this in order to get the list item height this.wrapper.css('visibility', 'hidden'); this.wrapper.show(); this.list_item_height = this.wrapper.find('li')[0].offsetHeight; this.wrapper.css('visibility', 'visible'); this.wrapper.hide(); }, setWidths: function() { // The text input has a right margin because of the background arrow image // so we need to remove that from the width var width = this.select.width() + 2; var padding_right = parseInt(this.text.css('padding-right').replace(/px/, ''), 10); this.text.width(width - padding_right); this.wrapper.width(width + 2); if(this.bg_iframe) { this.bg_iframe.width(width + 4); }; }, createBackgroundIframe: function() { var bg_iframe = $('<iframe frameborder="0" class="editable-select-iframe" src="about:blank;"></iframe>'); $(document.body).append(bg_iframe); bg_iframe.width(this.select.width() + 2); bg_iframe.height(this.wrapper.height()); bg_iframe.css({top: this.wrapper.css('top'), left: this.wrapper.css('left')}); this.bg_iframe = bg_iframe; } }; })(jQuery); $(function() { $('.editable-select').editableSelect( { bg_iframe: true, onSelect: function(list_item) { alert('List item text: '+ list_item.text()); // 'this' is a reference to the instance of EditableSelect // object, so you have full access to everything there // alert('Input value: '+ this.text.val()); }, case_sensitive: false, // If set to true, the user has to type in an exact // match for the item to get highlighted items_then_scroll: 10 // If there are more than 10 items, display a scrollbar } ); var select = $('.editable-select:first'); var instances = select.editableSelectInstances(); // instances[0].addOption('Germany, value added programmatically'); });

    Read the article

  • PHP, ImageMagick, Google's Page Speed, & JPG File Size Optimization

    - by Sonny
    I have photo gallery code that does image re-sizing and thumbnail creation. I use ImageMagick to do this. I ran a gallery page through Google's Page Speed tool and it revealed that the re-sized images and thumbnails both have about an extra 10KB of data (JPEG files specifically). What can I add to my scripts to optimize the file size? ADDITIONAL INFORMATION I am using the imagick::FILTER_LANCZOS filter with a blur setting of 0.9 when calling the resizeImage() function. JPEGs have a quality setting of 80.

    Read the article

  • JPG File Size Optimization - PHP, ImageMagick, & Google's Page Speed

    - by Sonny
    I have photo gallery code that does image re-sizing and thumbnail creation. I use ImageMagick to do this. I ran a gallery page through Google's Page Speed tool and it revealed that the re-sized images and thumbnails both have about an extra 10KB of data (JPEG files specifically). What can I add to my scripts to optimize the file size? ADDITIONAL INFORMATION I am using the imagick::FILTER_LANCZOS filter with a blur setting of 0.9 when calling the resizeImage() function. JPEGs have a quality setting of 80.

    Read the article

  • making jQuery plug-in autoNumeric format fields by time page loads...

    - by Lille
    Hi, I've been messing around with autoNumeric, a plug-in for jQuery that formats currency fields. I'd like to wire the plug-in so that all currency fields are formatted by the time the user sees the page, e.g., on load. Currently, the default that I can't seem to get around is that fields are formatted upon blur, key-up or other action in the fields themselves. I've been experimenting with the plug-in code and it looks like it will take this relative newcomer some time to resolve this, if at all. Anybody on this? Lille

    Read the article

  • Prototype Multi-Event Observation for Multi-Elements

    - by Phonethics
    ['element1','element2','element3'].each(function(e){ Event.observe(e, 'click', function(event){ ... }); Event.observe(e, 'blur', function(event){ ... }); Event.observe(e, 'mousedown', function(event){ ... }); Event.observe(e, 'mouseover', function(event){ ... }); }); Is there a way to reduce this so that I can do ['element1','element2','element3'].each(function(e){ Event.observe(e, ev, function(event){ switch(e){ switch (ev) } }); }); ?

    Read the article

  • Serverside image processing

    - by spol
    I am designing a web application that does server side image processing in real time. Processing tasks include applying different effects like grayscale, blur, oil paint, pencil sketch etc on images in various formats. I want to build it using java/servlets which I am already familiar with. I found 3 options, 1) Use pure java imaging libraries like java.awt or http://www.jhlabs.com/ip/index.html 2) Use command line tools like Gimp/ImageMagick 3) Use c,c++ image libraries that have java bindings. I don't know which of the above options is good keeping the performance in mind. It looks like option 2) and 3) are good performance wise, but I want to be sure before I rule out 1). I have also heard gimp cannot be run using command line unless gtk or xwindows is already installed on the server. Will there be any such problems with 2) or 3) while running them server side? Also please suggest any good image processing libraries for this purpose.

    Read the article

  • How do I fix incorrect inline Javascript indentation in Vim?

    - by Charles Roper
    I can't seem to get inline Javascript indenting properly in Vim. Consider the following: $(document).ready(function() { // Closing brace correctly indented $("input").focus(function() { $(this).closest("li").addClass("cur-focus"); }); // <-- I had to manually unindent this // Closing brace incorrectly indented $("input").blur(function() { $(this).closest("li").removeClass("cur-focus"); }); // <-- This is what it does by default. Argh! }); Vim seems to insist on automatically indenting the closing brace shown in the second case there. It does the same if I re-indent the whole file. How do I get it to automatically indent using the more standard JS indenting style seen in the first case?

    Read the article

  • Jquery Live Validation

    - by sico87
    Hello Everyone, After having a search around I could not find exactly what I want, I am looking to validate a form client side using the Jquery library and some form of validation plugin. I was hoping that some one could advise me on whether there are any validation plugins out there that do not use generic error messages, as my form is laid out with no room for these errors, and I also I want the validator to to for correct content as well. Basically I want to be able to check the field on each key press and blur and if the fields validates for it to gain a green border, and if it does not validate for it to gain a red border, any one know of a plugin that can do this? Thanks sico87

    Read the article

  • Jquery username check

    - by Sergio
    I'm using this Jquery function for available username check. How can I fire this Jquery function only if the username field is greater of 5 characters? Jquery looks like: $(document).ready(function() { $('#usernameLoading').hide(); $('#username').blur(function(){ $('#usernameLoading').show(); $.post("usercheck.php", { un: $('#username').val() }, function(response){ $('#usernameResult').fadeOut(); setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#usernameLoading').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } //finishAjax Can I use something like this and how: var usr = $("#username").val(); if(usr.length >= 5) { }

    Read the article

  • Retrieve Table Row Index of Current Row

    - by Jon
    Hi Everyone, I am trying to validate a text input when it loses focus. I would like to know which row of the table it is in. This is what I have so far and it keeps coming back as undefined. Any ideas? $("div#step-2 fieldset table tbody tr td input").blur(function() { var tableRow = $(this).parent().parent(); if ($.trim($(this).val()) == "") { $(this).addClass("invalid"); alert(tableRow.rowIndex); $(this).val(""); } else { $(this).removeClass("invalid"); checkTextChanges(); } });

    Read the article

  • Deselecting a form input and waiting for a function before submitting

    - by blcArmadillo
    I have a form with an input field where a user enters a unique identifier. I then have some jQuery code that upon the user moving away from the input field (blur) goes out and fetches details about the part and populates some fields on the page. The problem is if the user clicks the submit button before moving out of the input field the jQuery code never has a chance to load in the data and populate the necessary fields. Whats the best way to go about doing this? I thought about maybe setting the focus to body and then having an infinite loop that keeps checking the page until all fields that should be filled in have been filled in but I feel like some sort of event based solution would be better than unpredictable infinite loops. Any ideas?

    Read the article

  • To make the drawn text clear

    - by user1758835
    I have written the code to draw text on the image and to save the image,But the text which I am drawing is looking blur on the image.What modifications need to do to make it clear,Or if there is any other way to draw text on image in android Canvas canvas = new Canvas(photo); Typeface tf = Typeface.create(topaste, Typeface.BOLD); Paint paint = new Paint(); paint.setStyle(Style.FILL); paint.setTypeface(tf); paint.setColor(Color.WHITE); paint.setStrokeWidth(12); canvas.drawBitmap(photo, 0, 0, paint); canvas.drawText(topaste, 15, 120, paint); image.setImageBitmap(photo);

    Read the article

  • disallow selection inside an input element

    - by mkoryak
    I am looking to do the following Disallow text selection inside of an input element Do not show the cursor carrot inside of an input i cannot simply blur the input on click, focus must remain in the input. There is probably a way to do this in just IE, i would of course rather have a cross browser solution but ill settle for IE (or FF) only solution. Here is a demo page where you can see why i might need this functionality: http://programmingdrunk.com/current-projects/dropdownReplacement/ if you click on the dropdowns in the first row on page, you will see the carrot inside the dropdown which looks funny. (this wont happen in chrome, but will in FF or IE)

    Read the article

  • How to do the following in ListView

    - by Johnny
    How to do the following stuffs in ListView Only show scroll bar when user flip the list. By default, if the list is more than the screen, there is always a scrollbar on the right side. Is there a way to set this scrollbar only shows when user flip the list? Keep showing the list background image when scrolling. I've set an image as the background of the ListView, but when I scroll the list, the background image will disappear and only shows a black list view background. Is there any way to keep showing the list background image when scrolling? Don't show the shadow indicator. When the list has more items to display, there is a black-blur shadow to indicate user that there are more items. Is there a way to remove this item?

    Read the article

  • JQuery Scrollable List Dissapears if scrolled IE7

    - by namtax
    Hi there I have created a time picker using jquery, using the following code // Display Time Picker $('.time').click(function(){ $('.timePicker').remove(); var thisTime = $(this); var timePicker = '<ul class="timePicker">' timePicker += '<li>09:00</li>' timePicker += '<li>09:15</li>' timePicker += '</ul>' thisTime.after(timePicker); $('.timePicker').fadeIn() $('.timePicker li').click(function(){ term = $(this).html(); $(thisTime).val(term); $('.timePicker').remove(); }); }).blur(function(){ $('.timePicker').fadeOut(); }); This adds a dropdown scrollable list of times to any input field with the class "time". This functions as expected in all browsers apart from IE7, where if I scroll the list to choose a time lower down in the list, the list dissapears.. Hope that makes sense, any help would be much appreciated Many thanks

    Read the article

  • jquery tabIndex fix

    - by Victor
    On my pages(ASP.NET 3.5) where all input controls have tab order set whenever next input control is not enabled or hidden it goes to the address bar and then to next available control. To fix this behavior, i.e. make it land to the next available control w/o going to address bar I am trying to use jQuery: $(':text,textarea,select').blur(function() { $(this).next(':text, textarea, select').filter(':enabled:visible').focus(); }); But it still goes to the adress bar in some cases. What do I need to correct here?

    Read the article

  • jQuery getting text-shadow variabile

    - by Mircea
    Hi, I want to get 4 variables when I click on a span that have the CSS3 text-shadow propriety. So for a css propriety of text-shadow: -4px 11px 8px rgb(30, 43, 2);, my code should be: $("#element").click(function () { var text-shadow = $("#element").css("text-shadow") }); Would it be possible to get it split like: var y = "-4px"; var x = "11px"; var blur = "8px"; color = "rgb(30, 43, 2)"; I need to somehow split the first variable to get this data. Thanx

    Read the article

  • Preventing focus on next form element after showing alert using JQuery

    - by digitalsanctum
    I have some text inputs which I'm validating when a user tabs to the next one. I would like the focus to stay on a problematic input after showing an alert. I can't seem to nail down the correct syntax to have JQuery do this. Instead the following code shows the alert then focuses on the next text input. How can I prevent tabbing to the next element after showing an alert? $('input.IosOverrideTextBox').bind({ blur: function(e) { var val = $(this).val(); if (val.length == 0) return; var pval = parseTicks(val); if (isNaN(pval) || pval == 0.0) { alert("Invalid override: " + val); return false; } }, focus: function() { $(this).select(); } });

    Read the article

  • Android: Is there a universal way to send the MMS on any android devices?

    - by Roces
    This code works on the plain google devices with native android system. But there is no MMS app in the list on htc sense devices and I don't know about Motorola Blur etc.: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("image/png"); emailIntent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(emailIntent, context.getString(R.string.send_intent_name))); This code works on the htc sense but not from the Chooser, what I really need: Intent sendIntent = new Intent("android.intent.action.SEND_MSG"); sendIntent.putExtra(Intent.EXTRA_STREAM, uri); sendIntent.setType("image/png"); context.startActivity(sendIntent); But I don't know how to combine this code samples together and I don't know how to determine Htc Sense ui programmatically. Is it right way to support different type of devices? Thank you for answers.

    Read the article

  • regex jquery remove all double spaces

    - by michael
    Hi I have this code, I want it to remove all the double spaces from a text area, but it will only remove the first occurrence each time. $(document).ready(function(){ $("#article").blur(function(){ ///alert($(this).val()); $(this).val($(this).val().replace(/\s\s+/, ' ')); }); }); I've also tried removeAll(), but it won't work at all. any help would be great, thanks. I have a live example online at http://jsbin.com/ogasu/2/edit

    Read the article

  • PHP, MySQL, jQuery, AJAX: json data returns correct response but frontend returns error

    - by Devner
    Hi all, I have a user registration form. I am doing server side validation on the fly via AJAX. The quick summary of my problem is that upon validating 2 fields, I get error for the second field validation. If I comment first field, then the 2nd field does not show any error. It has this weird behavior. More details below: The HTML, JS and Php code are below: HTML FORM: <form id="SignupForm" action=""> <fieldset> <legend>Free Signup</legend> <label for="username">Username</label> <input name="username" type="text" id="username" /><span id="status_username"></span><br /> <label for="email">Email</label> <input name="email" type="text" id="email" /><span id="status_email"></span><br /> <label for="confirm_email">Confirm Email</label> <input name="confirm_email" type="text" id="confirm_email" /><span id="status_confirm_email"></span><br /> </fieldset> <p> <input id="sbt" type="button" value="Submit form" /> </p> </form> JS: <script type="text/javascript"> $(document).ready(function() { $("#email").blur(function() { var email = $("#email").val(); var msgbox2 = $("#status_email"); if(email.length > 3) { $.ajax({ type: 'POST', url: 'check_ajax2.php', data: "email="+ email, dataType: 'json', cache: false, success: function(data) { if(data.success == 'y') { alert('Available'); } else { alert('Not Available'); } } }); } return false; }); $("#confirm_email").blur(function() { var confirm_email = $("#confirm_email").val(); var email = $("#email").val(); var msgbox3 = $("#status_confirm_email"); if(confirm_email.length > 3) { $.ajax({ type: 'POST', url: 'check_ajax2.php', data: 'confirm_email='+ confirm_email + '&email=' + email, dataType: 'json', cache: false, success: function(data) { if(data.success == 'y') { alert('Available'); } else { alert('Not Available'); } } , error: function (data) { alert('Some error'); } }); } return false; }); }); </script> PHP code: <?php //check_ajax2.php if(isset($_POST['email'])) { $email = $_POST['email']; $res = mysql_query("SELECT uid FROM members WHERE email = '$email' "); $i_exists = mysql_num_rows($res); if( 0 == $i_exists ) { $success = 'y'; $msg_email = 'Email available'; } else { $success = 'n'; $msg_email = 'Email is already in use.</font>'; } print json_encode(array('success' => $success, 'msg_email' => $msg_email)); } if(isset($_POST['confirm_email'])) { $confirm_email = $_POST['confirm_email']; $email = ( isset($_POST['email']) && trim($_POST['email']) != '' ? $_POST['email'] : '' ); $res = mysql_query("SELECT uid FROM members WHERE email = '$confirm_email' "); $i_exists = mysql_num_rows($res); if( 0 == $i_exists ) { if( isset($email) && isset($confirm_email) && $email == $confirm_email ) { $success = 'y'; $msg_confirm_email = 'Email available and match'; } else { $success = 'n'; $msg_confirm_email = 'Email and Confirm Email do NOT match.'; } } else { $success = 'n'; $msg_confirm_email = 'Email already exists.'; } print json_encode(array('success' => $success, 'msg_confirm_email' => $msg_confirm_email)); } ?> THE PROBLEM: As long as I am validating the $_POST['email'] as well as $_POST['confirm_email'] in the check_ajax2.php file, the validation for confirm_email field always returns an error. With my limited knowledge of Firebug, however, I did find out that the following were the responses when I entered email and confirm_email in the fields: RESPONSE 1: {"success":"y","msg_email":"Email available"} RESPONSE 2: {"success":"y","msg_email":"Email available"}{"success":"n","msg_confirm_email":"Email and Confirm Email do NOT match."} Although the RESPONSE 2 shows that we are receiving the correct message via msg_confirm_email, in the front end, the alert 'Some error' is popping up (I have enabled the alert for debugging). I have spent 48 hours trying to change every part of the code wherever possible, but with only little success. What is weird about this is that if I comment the validation for $_POST['email'] field completely, then the validation for $_POST['confirm_email'] field is displaying correctly without any errors. If I enable it back, it is validating email field correctly, but when it reaches the point of validating confirm_email field, it is again showing me the error. I have also tried renaming success variable in check_ajax2.php page to other different names for both $_POST['email'] and $_POST['confirm_email'] but no success. I will be adding more fields in the form and validating within the check_ajax2.php page. So I am not planning on using different ajax pages for validating each of those fields (and I don't think it's smart to do it that way). I am not a jquery or AJAX guru, so all help in resolving this issue is highly appreciated. Thank you in advance.

    Read the article

  • Phonegap - iOS keyboard is not hiding on outside tap of input field

    - by Prasoon
    On input text focus, keyboard appears as expected. But when I click outside of the input text, keyboard does not hide. I am using java script and jQuery. With jQueryMobile JS and CSS - page behaves correctly. But for this project we are not using jQueryMobile. This problem is only with iOS simulator/device. With Android, it's working perfectly fine. I even tried using document.activeElement.blur(); on outer element click/tap. But then I am unable to focus to input text, because that input text is inside that outer element.

    Read the article

  • Jquery set defaults for all instances of a plugin

    - by Chris
    Given the following plugin how would you set defaults for all the instances? I would like it to work the same as $.datepicker.setDefaults(). (function ($) { $.fn.borderSwitcher = function (options) { defaults = { borderColor: 'Black', borderWidth: '1px', borderStyle: 'solid' }; return this.each(function () { var settings = $.extend(defaults, options); $(this).focus(function () { //find a better way to set border properties var props = settings.borderStyle + ' ' + settings.borderWidth + ' ' + settings.borderColor; $(this).css('border', props); }); $(this).blur(function () { $(this).css('border', ''); }); }); }; })(jQuery);

    Read the article

  • plugin instancing

    - by Hailwood
    Hi guys, I am making a jquery tagging plugin. I have an issue that, When there is multiple instances of the plugin on the page, if you click on any <ul> that the plugin has been called on it will put focus on the <input /> in the last <ul> that the plugin has been called on. Why is this any how can I fix it. $.widget("ui.tagit", { // default options options: { tagSource: [], triggerKeys: ['enter', 'space', 'comma', 'tab'], initialTags: [], minLength: 1 }, //private variables _vars: { lastKey: null, element: null, input: null, tags: [] }, _keys: { backspace: 8, enter: 13, space: 32, comma: 44, tab: 9 }, //initialization function _create: function() { var instance = this; //store reference to the ul this._vars.element = this.element; //add class "tagit" for theming this._vars.element.addClass("tagit"); //add any initial tags added through html to the array this._vars.element.children('li').each(function() { instance.options.initialTags.push($(this).text()); }); //add the html input this._vars.element.html('<li class="tagit-new"><input class="tagit-input" type="text" /></li>'); this._vars.input = this._vars.element.find(".tagit-input"); //setup click handler $(this._vars.element).click(function(e) { if (e.target.tagName == 'A') { // Removes a tag when the little 'x' is clicked. $(e.target).parent().remove(); instance._popTag(); } else { instance._vars.input.focus(); } }); //setup autcomplete handler this.options.appendTo = this._vars.element; this.options.source = this.options.tagSource; this.options.select = function(event, ui) { instance._addTag(ui.item.value); return false; } this._vars.input.autocomplete(this.options); //setup keydown handler this._vars.input.keydown(function(e) { var lastLi = instance._vars.element.children(".tagit-choice:last"); if (e.which == instance._keys.backspace) return instance._backspace(lastLi); if (instance._isInitKey(e.which)) { event.preventDefault(); if ($(this).val().length >= instance.options.minLength) instance._addTag($(this).val()); } if (lastLi.hasClass('selected')) lastLi.removeClass('selected'); instance._vars.lastKey = e.which; }); //setup blur handler this._vars.input.blur(function() { instance._addTag($(this).val()); $(this).val(''); }); //define missing trim function for strings String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); }; this._initialTags(); }, _popTag: function() { return this._vars.tags.pop(); } , _addTag: function(value) { this._vars.input.val(""); value = value.replace(/,+$/, ""); value = value.trim(); if (value == "" || this._exists(value)) return false; var tag = ""; tag = '<li class="tagit-choice">' + value + '<a class="tagit-close">x</a></li>'; $(tag).insertBefore(this._vars.input.parent()); this._vars.input.val(""); this._vars.tags.push(value); } , _exists: function(value) { if (this._vars.tags.length == 0 || $.inArray(value, this._vars.tags) == -1) return false; return true; } , _isInitKey : function(keyCode) { var keyName = ""; for (var key in this._keys) if (this._keys[key] == keyCode) keyName = key if ($.inArray(keyName, this.options.triggerKeys) != -1) return true; return false; } , _backspace: function(li) { if (this._vars.input.val() == "") { // When backspace is pressed, the last tag is deleted. if (this._vars.lastKey == this._keys.backspace) { this._popTag(); li.remove(); this._vars.lastKey = null; } else { li.addClass('selected'); this._vars.lastKey = this._keys.backspace; } } return true; } , _initialTags: function() { if (this.options.initialTags.length != 0) { for (var i in this.options.initialTags) if (!this._exists(this.options.initialTags[i])) this._addTag(this.options.initialTags[i]); } } , tags: function() { return this._vars.tags; } , destroy: function() { $.Widget.prototype.destroy.apply(this, arguments); // default destroy this._vars['tags'] = []; } }) ;

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13  | Next Page >