Jump to content

onblur failing / not initiating


cesarcesar

Recommended Posts

i am using the following AJAX request method. Most of you probably use this script allready as it seems to be everywhere online. I use it often with out issue... until now.

 

What I'm finding is that if the click used to initiate the onblur() used like

<input type="text" id="qty" name="qty" value="" onblur="makeRequest('ajax_insert.php?field_name=qty&field_value=',this.value);">

is on either a link or from submit button, the onblur() never gets called. In my code, the onblur() has to work if the user goes strait for the submit button before clicking anywhere else.

 

Any ideas on how to get it to call onblur() and refresh in a one click process? Thanks much for the help.

 

My AJAX code

function makeRequest(url, parameters) { 

http_request = false;

if (window.ActiveXObject) { // IE

	try {

		http_request = new ActiveXObject("Msxml2.XMLHTTP");

	} catch (e) {

		try {

			http_request = new ActiveXObject("Microsoft.XMLHTTP");

		} catch (e) {}

	}

} else if (window.XMLHttpRequest) { // Mozilla, Safari, Sometimes IE7...

	http_request = new XMLHttpRequest();

	if (http_request.overrideMimeType) {

		// set type accordingly to anticipated content type
		http_request.overrideMimeType('text/xml');
		// http_request.overrideMimeType('text/html');

	}else{ alert('Did not create *http_request.overrideMimeType*'); return false; }

} 

if (!http_request) {

	alert('Cannot create XMLHTTP instance');
	return false;

}

http_request.onreadystatechange = alertContents;

// FOR POST VARS
//http_request.open('POST', url, true);
//http_request.send(parameters);

// FOR GET VARS
//alert(url + parameters);
http_request.open('GET', url + parameters, true);
http_request.send(null);

}

function alertContents() {
if (http_request.readyState == 4) {
 if (http_request.status == 200) {
	//alert(http_request.responseText);
	result = http_request.responseText;
	document.getElementById('myspan').innerHTML = result;
 } else {
	alert('There was a problem with the request.');
 }
}
}

Link to comment
https://forums.phpfreaks.com/topic/99610-onblur-failing-not-initiating/
Share on other sites

hi if you want to do so you need to validate the text field on submit.using this user will fill out the data into the text fields..If you use onblur it works only if the value is entered or when we press TAB key on keyboard.Without this we can not initiate onblur for text field.i hope you understood...

  • 2 weeks later...

hi if you want to do so you need to validate the text field on submit.using this user will fill out the data into the text fields..If you use onblur it works only if the value is entered or when we press TAB key on keyboard.Without this we can not initiate onblur for text field.i hope you understood...

 

Incorrect! check out www.sincitybeats.com click on the Registration. I used onblur to check text fields even if blank. use ajax_function('div_name','file.php?value=this.value'); or something like that I have to look at my coding. Check out that site though.

Hi

 

You need to call all the function into button on click..

 

Using this you can do it..

 

For ex:

 

You use for email blank field validation in onblur like this onBlur="return validate_email();"..

 

you should use in button onclick="return validate()"..

 

<script>

function validate()

{

...............

.

.....

.

.

.

.

..............

validate_email();

 

.....

.

.

.

.

.................

}

</script>

 

you can do like this....

 

thanks

Shang.. :)

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.