Infopath表单:(生成的HTML)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="formview.aspx.cs" Inherits="formview" %>
<%@ Register TagPrefix="ss1" Namespace="Aspose.Form.Web.Controls" Assembly="Aspose.Form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>CheckEmail</title>
</head>
<body>
    
<form id="form1" runat="server">
<center>
    
<ss1:FormControl ID="FormControl" runat="server" />
   <input  type="button" value="CheckEmail" id="Checkemail" onclick="checkEmail();" />
 
</center>
 
</form>
</body>
</html>

FormControl就是infopath中的表单.

function getIdsByAttribute(bindingField)
{
    
var bindingIds=new Array();
    
var allInput=document.getElementsByTagName("input");
    
for(var b=0;b<=allInput.length-1;b++)
    
{
        
if(allInput[b].getAttribute("xd:binding")==bindingField)
        
{
            bindingIds.push(allInput[b].getAttribute(
"id"));
        }

    }

    
return bindingIds;
}



function checkEmail()
   

       
var email = document.getElementById(getIdsByAttribute("my:email")[0]);   
        
if(email.value!= ""
        
{   
            
if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(email.value))    
           
{   
               alert(
"Email format is error! please try again.");   
               email.focus ();   
           }
    
           
else    
           
{      
                alert("Email is right");

                
return;
           }
   
       }
   
       
else
       
{
            alert(
"Please type in you email.");
            email.focus (); 
       }

   }
 

 

 


posted on 2007-09-27 14:24  ◎寶☆呗  阅读(429)  评论(2)    收藏  举报