Re: [jQuery] Tiny plugin example, message box

2007-01-10 Thread Allan Mullan (Skorpion)
Yeah I'm working on one now - not easy as you have to factor
in alot of things (i.e. do you have events fire on
onchange() or onsubmit() and if you use onchange() there are
some that must be checked onsubmit()) - it's a bit of a
nightmare.


Allan

- Original Message Follows -
> I think there are some full-fledged
> form ateTest.html>
> validation alidator/form_validate.html>plugins around. Even if none
> of them are quite what you're after they could probably
> give you some ideas.
> 
> Blair
> 
> On 1/11/07, Mike Alsup <[EMAIL PROTECTED]> wrote:
> >
> > > $.fn.isEmpty = function() {
> > > var isempty = true;
> > >
> > > this.each(
> > > function() {
> > > if (this.value.length != 0) {
> > > isempty = false;
> > > }
> > > }
> > > );
> > > return isempty;
> > > }
> > >
> >
> > If you're using the form plugin on that page you could
> also do: >
> > if (!$('#myForm *').fieldValue()) {
> > alert('blah');
> > }
> >
> > - or -
> >
> > if (!$('#testForm').formToArray().length) {
> > alert('blah');
> > }
> >
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
> 
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Tiny plugin example, message box

2007-01-10 Thread Blair McKenzie

I think there are some full-fledged
form
validationplugins
around. Even if none of them are quite what you're after they could
probably give you some ideas.

Blair

On 1/11/07, Mike Alsup <[EMAIL PROTECTED]> wrote:


> $.fn.isEmpty = function() {
> var isempty = true;
>
> this.each(
> function() {
> if (this.value.length != 0) {
> isempty = false;
> }
> }
> );
> return isempty;
> }
>

If you're using the form plugin on that page you could also do:

if (!$('#myForm *').fieldValue()) {
alert('blah');
}

- or -

if (!$('#testForm').formToArray().length) {
alert('blah');
}

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Tiny plugin example, message box

2007-01-10 Thread Mike Alsup
> $.fn.isEmpty = function() {
> var isempty = true;
>
> this.each(
> function() {
> if (this.value.length != 0) {
> isempty = false;
> }
> }
> );
> return isempty;
> }
>

If you're using the form plugin on that page you could also do:

if (!$('#myForm *').fieldValue()) {
alert('blah');
}

- or -

if (!$('#testForm').formToArray().length) {
alert('blah');
}

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Tiny plugin example, message box

2007-01-10 Thread James Thomas

Hey all,

I've just discovered Jquery this last weekend and I am now converting all of
my in-house Javascript to use it. I played with most of the others but
didn't really like any of them; then I found Jquery and was instantly hooked
- the website is right, it does make javascript fun.

Anyway, I've started digging into some of the plugins and got around to
making my own. I do a lot of form validation (are certain fields provided,
etc.). I need to regularly check textbox/textarea fields for data so I did
the following plugin:

$.fn.isEmpty = function() {
var isempty = true;

this.each(
function() {
if (this.value.length != 0) {
isempty = false;
}
}
);
return isempty;
}

Any thoughts on ways I could improve this?

And not really a plugin but some simple Javascript that uses jquery to
generate a message on screen that fades away on its own (it gets its
stylings from CSS). Feel free to use it and/or suggest improvements:

var Msg = {
FadeIn : 750,

FadeOut : 1500,

FadeDelay : 2200,

// Show a formatted box on the screen - arguments:
//  lft : Left position (optional - if not 
provided, uses CSS default)
//  tp  : Top position (optional - if not 
provided, uses CSS default)
//  fin : Fade In Speed (optional - if not 
provided, use default)
//  fout: Fade Out Speed (optional - if not provided, 
use default)
//  delay   : How long to delay between fade in and 
starting fade out
(optional - if not provided, use default)
Show : function(msg, tp, lft, fin, fout, delay)
{
// Create the div tag we're going to display
$('body').append("" + msg + "");

// Get the necessary tag
var jq = $('div.message');

// Clicking anywhere within the message will cause it to close 
before fade
out effect finishes
jq.click(function() { $(this).unclick().remove() });

// Set some defaults if they haven't been passed in
delay = delay || Msg.FadeDelay;

fout = fout || Msg.FadeOut;

fin = fin || Msg.FadeIn;

// Use the defaults from CSS
lft = lft || jq.css("left");

tp = tp || jq.css("top");

// If no message provided, use a default one
msg = msg || "Message not provided.";

// Now display it
jq.css({ left : lft, top: tp }).fadeIn(fin, function() { 
setTimeout("$('div.message').fadeOut(" + fout + ", 
function() {
$(this).unclick().remove();} );", delay); });
}
};




-- 
View this message in context: 
http://www.nabble.com/Tiny-plugin-example%2C-message-box-tf2955841.html#a8268666
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/