Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Prototype JS

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Eric

VIP Member
Impact
328
Ok, I'm not too well versed in JavaScript, but I can work with it. I recently downloaded Prototype/Scriptalicious. I'm slowly trying to replace certain parts of a site with the prototype.

I was wondering if any of you more experienced folks could tell me if something like this would work? Or, maybe if you have a better way of doing it.

It's basically waiting for the form to be submitted, then it will check the form fields.

Code:
Event.observe(window, 'load', function()
{
	$('form').observe('submit', function()
	{
		// Check Name
		if ($('sender_name').value == '' || $('sender_name').value == null)
		{
			error_msg += "\n Please enter your name";
		}

		// Check email
		if ($('sender_email').value == '' || $('sender_email').value == null)
		{
			error_msg += '\n Please enter a valid email address';
		}

		// Check Message
		if ($('sender_subject').value == '' || $('sender_subject').value == null)
		{
			error_msg += "\n Please choose a subject";
		}

		// Check Message
		if ($('sender_message').value == '' || $('sender_message').value == null)
		{
			error_msg += "\n Please enter a message";
		}

		// Check CAPTCHA
		if ($('captcha').value.search(/^[a-z0-9]{5}$/i) == -1)
		{
			error_msg += "\n Please enter the CAPTCHA code";
		}

		if (error_msg != "The following errors occurred:\n")
		{
			window.alert(error_msg);
			return false;
		}
		return true;
	});
});
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back