Jump to content

.focus() not working right


severndigital

Recommended Posts

maybe i am going about this the wrong way .. but here is what i want to do

 

1. check a field input

2. if false clear the field and then

3. return focus to the empty field.

 

I have this up and running at the following link

http://chernay.homedns.org/mystore/signup/create_account

 

the email field validates and check for incorrect email.

 

function validate_email()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(reg.test($('#emailaddress').val()) == false)
{
	alert('Email Address does not appear to be valid.');
	$("#emailaddress").val('');
	$("#emailaddress").focus();
	return false;

}
}

 

the email address validates correctly, but when you type in something that isn't an email address.

the alert pops up. but when you hit ok, it clears the field and moves the the next one.

 

instead of going back to the email address field.

 

any suggestions? I know it is my just doing something wrong, i just can't figure out what.

thanks,

Link to comment
https://forums.phpfreaks.com/topic/223130-focus-not-working-right/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.