Advertisement
C_Volume2 Forms Validation Processing #81117

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

Riepilogo 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.

Codice sorgente
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);">
Commenti originali (3)
Recuperato da Wayback Machine