In the following script I think it’s validating form labels: test number, test year, test type ,serial and pin numbers stored in a database - right? - otherwise what is it doing?
Also, I do not get the part containing the regular expression.
Note: this is not my handiwork but I want to make a chit with serial and pin numbers which gets exhausted when used thrice and only unique to a user on 1st use: thus a user may need a new chit for subsequent check after it’s used thrice.
<script language="JavaScript" type="text/JavaScript">
function test ()
{
var TestNumber = document.getElementById ("txtTestNumber");
var TestYear = document.getElementById ("drpTestYear");
var serial = document.getElementById ("txtCardSerialNo");
var pin = document.getElementById ("txtPIN");
if ( trim (Test Number.value) == ' ' )
{
alert ('Test Number cannot be blank');
return;
}
// if conditions for the rest of the variables
var qrystr = ' ?TestNumber=' + trim ( TestNumber.value) + '& TestYear= ' + TestYear.value + '&serial=' + trim( serial.value) + '&pin=' + trim(pin.value)
//alert(qrystr);
window.open('DisplayResult.aspx' + qrystr, " ", 'scrollbars, width=500, height=680');
}
function 1trim (str, chars) {
chars || " \\s" ;
return str.replace (new RegExp ("^ [" + chars + "] +", " g "), " ") ;
}
function rtrim (str, chars) {
chars = chars || "\\s" ;
return str.replace (new RegExp (" [" + chars + " ] +$", "g"), "");
}