Submits a message across the domain and returns whether it was successful.
C # Service side:
public void Feedbackpost (string name, string email, string tel, string website, string desc, String Thisip, String sourse, String callBack) {try {Response.ContentType = ' application/x-javascript
";
string str = CallBack;
if (thisip==null) {Thisip = "Not taken to IP";
} String strSQL = "";
Hsby_dbentities db = new hsby_dbentities (); Verify that too many Regex Rx is committed in the IP short time = new Regex (?:(? : 25[0-5]|2[0-4]\d| ((1\d{2}) | ([1-9]?\d))] \.) {3} (?: 25[0-5]|2[0-4]\d| ((1\d{2}) |
([1-9]?\d))]); if (Rx. IsMatch (Thisip)) {strSQL = @ "SELECT COUNT (*) from Fb_srv_main where ip= '" + Thisip +
"'"; int ipcount = db. Executestorequery<int> (strSQL).
FirstOrDefault (); if (ipcount>10) {str = "([{\"Do not repeat submissions."
\"}]);";
Response.Write (str);
Return
} fb_srv_main newitem = new Fb_srv_main ();
Newitem.name = name;
Newitem.email = email;
Newitem.tel = Tel;
Newitem.site = website;
NEWITEM.CONTENT_STR = desc;
Newitem.ip = Thisip;
newitem.creat_by = Sourse;
newitem.creat_on = DateTime.Now;
_mainbll.create (ref validationerrors, newitem);
HttpContext context = new HttpContext (); if (validationerrors.count>0) {str+=validationerrors[0].
errormessage;
Response.Write (str);
Return
Feedbackemail (name, email, tel, website, desc, Thisip, sourse); str = "([{\" rusltstr\ ": \" Ok\ "}]);";
Response.Write (str);
Return
catch (Exception ex) {Response.ContentType = "application/x-javascript"; Response.Write (CallBack + "[{\" rusltstr\ ": \" has gone wrong.)
\"}]);");
Return }
}
JS Client:
Submit message returns data processing
function Displayresult (data) {
var irusltstr=data[0]. Rusltstr;
if (irusltstr== "OK") {
//close mask
$ ("#submitmask"). fadeout;
Alert ("committed successfully.") ");
} else{
$ ("#submitmask"). fadeout;
Alert (irusltstr+) please contact us using other means. ");
}
Submit Message Function submitmsg () {var allinput=$ ("#formwrap input");
var itextarea=$ ("#formwrap textarea");
Gets the focus style allinput.focus (function () {Addfocusstyle ($ (This))});
Allinput.blur (function () {Addfocusstyle ($ (This))});
Itextarea.focus (function () {Addfocusstyle ($ (This))});
Itextarea.blur (function () {Addfocusstyle ($ (This))}); function Addfocusstyle (iinput) {if (Iinput.attr ("style") = = "| | iinput.attr (" style ") ==null) {iinput.attr (" style ")
"border:1px solid #bcbcbc; color: #7a7a7a;");
}else{iinput.attr ("style", "");
}//Missing Focus validation Allinput.blur (function () {Formvaliudat ($ (this));
});
Form Validation method function Formvaliudat ($input) {var promptstr= "";
var pattern = new RegExp ("[~ '!#$%^&* ()-+_=]"); if (Pattern.test ($input. Val ())) {alert ("illegal character.) Kiss, please do not try to inject oh.
");
return false; Switch ($input. attr ("id")) {case "name"://Surname if ($input. Val (). length>10) {$ ("# Redpoint_name "). RemoveClass ("Hide");
$input. focus ();
return false;
}else{$ ("#redpoint_name"). AddClass ("Hide");
} break; Case "Email"://email var reg =/^[a-z0-9]+ ([. _\\-]*[a-z0-9]) *@ ([a-z0-9]+[-a-z0-9]*[a-z0-9]+.) {1,63}
[a-z0-9]+$/;
if (!reg.test ($input. Val ())) {$ ("#redpoint_email"). Removeclass ("Hide");
$input. focus ();
return false;
}else{$ ("#redpoint_email"). AddClass ("Hide");
} break;
Case "TEL"://Telephone var ismobile=/^ (?: 13\d|15\d|18\d) \d{5} (\d{3}|\*{3}) $/; var isphone=/^ ((0\d{2,3})-)? (\d{7,8})
(-(\d{3,}))? $/;
if (!ismobile.test ($input. Val ()) &&!isphone.test ($input. Val ())) {$ ("#redpoint_tel"). Removeclass ("Hide");
$input. focus ();
return false;
}else{$ ("#redpoint_tel"). AddClass ("Hide");
} break; Case "website": if (!) (
/[^\d]/g). Test ($input. Val ())) {$ ("#redpoint_website"). Removeclass ("Hide"); $Input.focus ();
return false;
}else{$ ("#redpoint_website"). AddClass ("Hide");
} break;
Case "desc": Var maintext= $input. Val (); if (maintext.length>=100) {alert ("up to 100 words.")
");
return false;
} break;
return true;
//Form Submit $ ("#formsubmit"). Click (function () {var $feedback _input=$ ("#formleft input");
for (var i=0;i< $feedback _input.length;i++) {var $thisInput =$ ($feedback _input[i]); if (!
Formvaliudat ($thisInput)) {return;
};
///Submit the form before opening the mask $ ("#submitmask"). FadeIn (500); var url = "http://www. Xxxx.cn:8888/mainajax/feedbackpost "url =" Http://www.<span style= "font-family:arial, Helvetica, Sans-serif;" >xxxx</span><span style= "font-family:arial, Helvetica, Sans-serif;" >.cn:8888/mainajax/feedbackpost?name= "+$ (" #name "). Val () +" &email= "+$ (" #email "). Val () +" &tel= "+$ (" #tel "). Val () +" &website= "+$ (" #website ").Val () + "&desc=" +$ ("#desc"). Val () + "&thisip=" +$ ("#keleyivisitorip"). HTML () + "&callback=displayresult"
</span> $.getscript (URL); })
}