Regular Expression batch verification functions
Function checkdata (){
// Determine the correctness of the data
VaR idspans = new array ();
Idspans [0] = new array ("item_4", "^ [\ s] {1, 16} $", "productname ", "The business opportunity name should be 1-16 characters or less", "Idspans [1] = new array ("item_5", "^ [\ s] {1, 16} $", "ptitle ", "The business opportunity title should be 1-16 characters or less", "Idspans [2] = new array ("item_3_2", "^ [\ s] + $", "iditem_3_2spans", "Business Opportunity category cannot be blank ", "Idspans [3] = new array ("item_7", "^ [\ s] + $", "iditem_7spans", "product series cannot be blank ", "Idspans [4] = new array ("item_8_1", "^ [\ s] {2, 30} $", "iditem_8_1spans ", "The business opportunity must be 2-30 characters in length", "Idspans [5] = new array ("item_8_2", "^ [\ s] {2, 30} $", "iditem_8_1spans ", "The business opportunity must be 2-30 characters in length", "Idspans [6] = new array ("item_8_4", "^ [\ D] + $", "iditem_8_4spans", "Business Opportunity quantity is in digital format ", "Idspans [7] = new array ("item_8_6", "^ [0-9] + [\.]? [0-9] * $ "," iditem_8_6spans "," the unit price can only consist of numbers and decimal places !! "," ", false );
// Idspans [8] = new array ("item_9", "^ [\ s] {16 ,}$", "iditem_9spans ", "The description cannot be less than 16 characters", "// Idspans [9] = new array ("item_1_1", "^ [\ s] + $", "iditem_1_1spans", "Business Opportunity image cannot be blank ", "
VaR reg;
VaR textvalue;
For (VAR I = 0; I <idspans. length; I ++)
{
Reg = new Regexp (idspans [I] [1], "IgM ");
Textvalue = Document. getelementbyid (idspans [I] [0]). value;
If (textvalue. length> 0 | idspans [I] [5])
{
If (Reg. Test (textvalue ))
{
Document. getelementbyid (idspans [I] [2]). innerhtml = "<font color = 'green'>" + idspans [I] [4] + "</font> ";
}
Else
{
Try
{
Document. getelementbyid (idspans [I] [0]). Focus ();
}
Catch (E)
{
}
Document. getelementbyid (idspans [I] [2]). innerhtml = "<font color = 'red'>" + idspans [I] [3] + "</font> ";
Return false;
}
Alert (textvalue );
}
}
// Alert (document. getelementbyid ('item _ 3_2 '). Options. Length );
If (document. getelementbyid ('item _ 3_3 '). Options. length> 0 & document. getelementbyid ('item _ 3_3'). selectedindex <0)
{
Document. getelementbyid ("iditem_3_2spans"). innerhtml = "the last category should be selected! ";
Document. getelementbyid ("item_3_3"). Focus ();
Return false;
}
Return true;
}