Advertisement
4_2005-2006 Forms Validation Processing #161326

Validate an HTML form control against a database without submission

I was fed up with entering a username on various websites, posting the form only for it to return with a server posted message that the username was already in use. This function will alert the user if the value he had entered was found to be already existing without the form being submitted. Later flavours of I.E. only

AI

ИИ-обзор: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Исходный код
original-source
// <!-- script for the header/js file --> //
function validateuserid(item,suserid) 
{
	document.body.style.cursor='wait';
	// Create an instance of the XML HTTP Request object
	var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );	
	// Prepare the XMLHTTP object for a HTTP POST to our validation ASP page
	// enter the path to your validation ASP[X]
	var sURL = "http://yourdomain/yourvalidatingpage.asp?userID=" + suserid
	oXMLHTTP.open( "GET", sURL, false );
	// Execute the request
	oXMLHTTP.send();
	if (oXMLHTTP.responseText == "exists") // if the ASP response.writes the string "exists" then
	{
		alert("Sorry - the User ID\n " + suserid + "\nalready exists!");
		item.value="";
		item.focus();
	}
	
	document.body.style.cursor='auto';
}
// <!-- HTML form control to validate --> //
<INPU[T] type=text maxLength=30 size=30 value="" name="username" class=TextBox onblur="validateuserid(this,this.value);">

Upload
Оригинальные комментарии (3)
Восстановлено из Wayback Machine