cē楽屋出力javascript文の例プログラム
4309 ワード
using System;
using System.Web;
using System.IO;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
namespace MyOraComm
{
/// <summary>
/// FuncTion 。
/// </summary>
public class Function
{
public Function()
{
//
// TODO:
//
}
// ====== ==============================================================================
//========================= ================================
//=======================================================================================
#region javascript , 。
public void WriteMessage(string strMsg,bool Back,bool End)
{
HttpContext Context=HttpContext.Current;
strMsg=strMsg.Replace("'","");
strMsg=strMsg.Replace("/r/n","");
if(strMsg!=""&&strMsg!=null)
Context.Response.Write("<script language=javascript>alert('"+strMsg+"');</script>");
if(Back)
Context.Response.Write("<script language=javascript>history.back();</script>");
if(End)
Context.Response.End();
}
#endregion
#region javascript ,<script language=javascript></script> 。
public void WriteJavaScript(string strJavaScript)
{
HttpContext Context=HttpContext.Current;
Context.Response.Write("<script language=javascript>"+strJavaScript+"</script>");
}
#endregion
#region
public void CloseWindow()
{
HttpContext Context=HttpContext.Current;
Context.Response.Write("<script language=javascript>window.close();</script>");
Context.Response.End();
}
#endregion
//====================================================================================
//========================= ================================
//=====================================================================================
#region .
public bool IsValidNumer(string str)
{
System.Text.RegularExpressions.Regex reg1
= new System.Text.RegularExpressions.Regex(@"^[-]?/d+[.]?/d*$");
return reg1.IsMatch(str);
}
#endregion
#region
public bool IsValidDecimal(string str)
{
return Regex.IsMatch(str,@"[0]./d{1,2}|[1]");
}
#endregion
#region Email
public bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn, @"^([/w-/.]+)@((/[[0-9]{1,3}/.[0-9]{1,3}/.[0-9]{1,3}/.)|(([/w-]+/.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(/]?)$");
}
#endregion
#region dd-mm-yy mm/dd/yy 。
public string MDYToDMY(String input)
{
return Regex.Replace(input,"//b(?//d{1,2})/(?//d{1,2})/(?//d{2,4})//b","${day}-${month}-${year}");
}
#endregion
#region
public bool IsValidTelNum(string strIn)
{
return Regex.IsMatch(strIn,@"(/d+-)?(/d{4}-?/d{7}|/d{3}-?/d{8}|^/d{7,8})(-/d+)?");
}
#endregion
#region
bool IsValidDate(string strIn)
{
return Regex.IsMatch(strIn,@"^2/d{3}-(?:0?[1-9]|1[0-2])-(?:0?[1-9]|[1-2]/d|3[0-1])(?:0?[1-9]|1/d|2[0-3])?:0?[1-9]|[1-5]/d)?:0?[1-9]|[1-5]/d)$");
}
#endregion
#region
bool IsValidPostfix(string strIn)
{
return Regex.IsMatch(strIn,@"/.(?i:gif|jpg)$");
}
#endregion
#region 4 12
bool IsValidByte(string strIn)
{
return Regex.IsMatch(strIn,@"^[a-z]{4,12}$");
}
#endregion
#region IP
bool IsValidIp(string strIn)
{
return Regex.IsMatch(strIn,@"^(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])$");
}
#endregion
}
}