Email Address Validation Function

本文详细介绍了对已交付代码中硬编码的页面字段进行优化,将静态内容转换为动态处理的过程,并具体阐述了电子邮件地址验证函数的实现细节,包括字符验证、格式检查以及异常处理逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Did some changes in the delivered code. Page fields were hard coded in the delivered code, made it dynamic.


Function validateEmailAddressEntry(&Email_Addr As string, &Page_Field As string)


Local string &Email_After@, &str_Host, &local_part, &Domain_part;
Local number &Loc@, &Loc_dot, &next_dot, &local_LENGTH, &Domain_length, &LOOP;
Local string &ALPHA_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-";
Local string &char_String = "#$%&'*+/=?^_`{|}~";
Local string &NUM_STRING = "1234567890";


&Email_Addr = RTrim(LTrim(&Email_Addr));


If All(&Email_Addr) Then
&Loc@ = Find("@", &Email_Addr);
&Loc_dot = Find(".", &Email_Addr);


&local_part = Substring(&Email_Addr, 1, &Loc@ - 1);
&Domain_part = Substring(&Email_Addr, &Loc@ + 1, Len(&Email_Addr) - &Loc@);
&local_LENGTH = Len(&local_part);
&Domain_length = Len(&Domain_part);
&Email_After@ = Substring(&Email_Addr, &Loc@ + 1, Len(&Email_Addr) - &Loc@);


/* The e-mail address must contain @ and . characters */
If &Loc@ = 0 Or
&Loc_dot = 0 Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 895, "The e-mail address must contain @ and . characters");
End-If;


/* The e-mail address shall not contain @ or . at the first character. */
If &Loc@ = 1 Or
&Loc_dot = 1 Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 896, "The e-mail address shall not contain @ or . at the first character.");
End-If;


/* Two at signs (@) are not allowed */
If (Find("@", &Email_After@) > 0) Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 899, "Two at signs (@) are not allowed");
End-If;


/* The e-mail address shall not contain - as the first character in Domain name. */
If (Find("-", &Email_After@) = 1) Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 900, "The e-mail address shall not contain - as the first character in Domain name.");
End-If;


/* The e-mail address shall contain atleast one character between @ and . */
If ((Substring(&Email_Addr, &Loc@ - 1, 1) = ".") Or
(Substring(&Email_Addr, &Loc@ + 1, 1) = ".")) Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 901, "The e-mail address shall contain atleast one character between @ and .");
End-If;


/* The e-mail address shall not contain @ or . at the last character. */
If ((Substring(&Email_Addr, Len(&Email_Addr), 1) = ".") Or
(Substring(&Email_Addr, Len(&Email_Addr), 1) = "@")) Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 897, "The e-mail address shall not contain @ or . at the last character.");
End-If;


If (&Loc_dot > 1) Then


/* */
&str_Host = Substring(&Email_Addr, &Loc_dot + 1, Len(&Email_Addr) - &Loc_dot);
&next_dot = Find(".", &str_Host);


While &next_dot > 0
If &next_dot = 1 Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 902, "The e-mail address shall contain atleast one character between . and .");
Break;
Else
&Loc_dot = &next_dot;
&Email_After@ = &str_Host;
&str_Host = Substring(&str_Host, &next_dot + 1, Len(&str_Host) - &next_dot);
&next_dot = Find(".", &str_Host);
End-If;
End-While;


If Len(&str_Host) < 2 Then SetCursorPos(%Page, @(&Page_Field)); Error MsgGet(14100, 903, "The e-mail address should contain atleast two characters after last ."); End-If; End-If; /* Validate that the local part consists of the ascii characters are described above for local part */ &LOOP = 1; While &LOOP <= &local_LENGTH /* check for alpha in the format */ If ((Find(Substring(&local_part, &LOOP, 1), &ALPHA_STRING) = 0) And (Find(Substring(&local_part, &LOOP, 1), &NUM_STRING) = 0) And (Find(Substring(&local_part, &LOOP, 1), &char_String) = 0)) Then SetCursorPos(%Page, @(&Page_Field)); Warning MsgGet(14100, 904, "Invalid character found in local part of email address."); Break; End-If; &LOOP = &LOOP + 1; End-While; /* Validate that domain name consists letters, digits and hyphens separated by dots */ &LOOP = 1; While &LOOP <= &Domain_length /* check for alpha in the format */ If ((Find(Substring(&Domain_part, &LOOP, 1), &ALPHA_STRING) = 0) And (Find(Substring(&Domain_part, &LOOP, 1), &NUM_STRING) = 0)) Then Warning MsgGet(14100, 905, "Invalid character found in domain part of email address."); Break; End-If; &LOOP = &LOOP + 1; End-While; /* Validate that the local part consists of at least 1 character before the @ sign but not more than 64 characters*/ If &local_LENGTH < 1 Or &local_LENGTH > 64 Then
SetCursorPos(%Page, @(&Page_Field));
Warning MsgGet(14100, 894, "Length of Local part of e-mail address before the @ sign must be >=1 and <= 64.");
End-If;


/* Make sure that atleast two characters are present between @ and . */
&Email_After@ = Substring(&Email_Addr, &Loc@ + 1, Len(&Email_Addr) - &Loc@);
&Loc_dot = Find(".", &Email_After@);
If (&Loc_dot = 0) Then
SetCursorPos(%Page, @(&Page_Field));
Error MsgGet(14100, 895, "The e-mail address must contain @ and . characters");


End-If;
End-If;


End-Function;
内容概要:本文详细介绍了扫描单分子定位显微镜(scanSMLM)技术及其在三维超分辨体积成像中的应用。scanSMLM通过电调透镜(ETL)实现快速轴向扫描,结合4f检测系统将不同焦平面的荧光信号聚焦到固定成像面,从而实现快速、大视场的三维超分辨成像。文章不仅涵盖了系统硬件的设计与实现,还提供了详细的软件代码实现,包括ETL控制、3D样本模拟、体积扫描、单分子定位、3D重建和分子聚类分析等功能。此外,文章还比较了循环扫描与常规扫描模式,展示了前者在光漂白效应上的优势,并通过荧光珠校准、肌动蛋白丝、线粒体网络和流感A病毒血凝素(HA)蛋白聚类的三维成像实验,验证了系统的性能和应用潜力。最后,文章深入探讨了HA蛋白聚类与病毒感染的关系,模拟了24小时内HA聚类的动态变化,提供了从分子到细胞尺度的多尺度分析能力。 适合人群:具备生物学、物理学或工程学背景,对超分辨显微成像技术感兴趣的科研人员,尤其是从事细胞生物学、病毒学或光学成像研究的科学家和技术人员。 使用场景及目标:①理解和掌握scanSMLM技术的工作原理及其在三维超分辨成像中的应用;②学习如何通过Python代码实现完整的scanSMLM系统,包括硬件控制、图像采集、3D重建和数据分析;③应用于单分子水平研究细胞内结构和动态过程,如病毒入侵机制、蛋白质聚类等。 其他说明:本文提供的代码不仅实现了scanSMLM系统的完整工作流程,还涵盖了多种超分辨成像技术的模拟和比较,如STED、GSDIM等。此外,文章还强调了系统在硬件改动小、成像速度快等方面的优势,为研究人员提供了从理论到实践的全面指导。
内容概要:本文详细介绍了基于Seggiani提出的渣层计算模型,针对Prenflo气流床气化炉中炉渣的积累和流动进行了模拟。模型不仅集成了三维代码以提供气化炉内部的温度和浓度分布,还探讨了操作条件变化对炉渣行为的影响。文章通过Python代码实现了模型的核心功能,包括炉渣粘度模型、流动速率计算、厚度更新、与三维模型的集成以及可视化展示。此外,还扩展了模型以考虑炉渣组成对特性的影响,并引入了Bingham流体模型,更精确地描述了含未溶解颗粒的熔渣流动。最后,通过实例展示了氧气-蒸汽流量增加2%时的动态响应,分析了温度、流动特性和渣层分布的变化。 适合人群:从事煤气化技术研究的专业人士、化工过程模拟工程师、以及对工业气化炉操作优化感兴趣的科研人员。 使用场景及目标:①评估不同操作条件下气化炉内炉渣的行为变化;②预测并优化气化炉的操作参数(如温度、氧煤比等),以防止炉渣堵塞;③为工业气化炉的设计和操作提供理论支持和技术指导。 其他说明:该模型的实现基于理论公式和经验数据,为确保模型准确性,实际应用中需要根据具体气化炉的数据进行参数校准。模型还考虑了多个物理场的耦合,包括质量、动量和能量守恒方程,能够模拟不同操作条件下的渣层演变。此外,提供了稳态求解器和动态模拟工具,可用于扰动测试和工业应用案例分析。
var Login = function() { var handleLogin = function() { $('.login-form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block', // default input error message class focusInvalid: false, // do not focus the last invalid input rules: { username: { required: true }, password: { required: true }, remember: { required: false } }, messages: { username: { required: "用户名必须输入." }, password: { required: "密码必须输入." } }, invalidHandler: function(event, validator) { //display error alert on form submit $(".alert-danger").find("span").html(validator.errorList[0].message); $('.alert-danger', $('.login-form')).show(); //显示信息 }, highlight: function(element) { // hightlight error inputs $(element) .closest('.form-group').addClass('has-error'); // set error class to the control group }, success: function(label) { label.closest('.form-group').removeClass('has-error'); label.remove(); }, errorPlacement: function(error, element) { error.insertAfter(element.closest('.input-icon')); }, submitHandler: function(form) { // form.submit(); // form validation success, call ajax form submit //ajax请求 进入如果成功登陆则跳转到基本页面 } }); $('.login-form input').keypress(function(e) { if (e.which == 13) { $("#bt_login").click(); return false; } }); $("#bt_login").click(function(){ $('.alert-danger', $('.login-form')).hide(); // if ($('.login-form').validate().form()) { $.ajax({ type: "POST", url: $('.login-form').attr("action"), data:{username:$("#username").val(),password:$("#password").val()}, dataType:"json", timeout:5000, success:function(result){ if(isSuccess(result)){ //登录成功 跳转到页面 location.href=base_path+"/gateway_do/modal/dashboard"; }else{ $(".alert-danger").find("span").html("用户登录失败!"); $('.alert-danger', $('.login-form')).show(); //显示信息 } }, error:function(request, status, err) { $(".alert-danger").find("span").html("用户登录失败!"); $('.alert-danger', $('.login-form')).show(); //显示信息 } }); } }); } var handleForgetPassword = function() { $('.forget-form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { email: { required: true, email: true, } }, messages: { email: { required: "Email is required." } }, invalidHandler: function(event, validator) { //display error alert on form submit }, highlight: function(element) { // hightlight error inputs $(element) .closest('.form-group').addClass('has-error'); // set error class to the control group }, success: function(label) { label.closest('.form-group').removeClass('has-error'); label.remove(); }, errorPlacement: function(error, element) { error.insertAfter(element.closest('.input-icon')); }, submitHandler: function(form) { form.submit(); } }); $('.forget-form input').keypress(function(e) { if (e.which == 13) { if ($('.forget-form').validate().form()) { $('.forget-form').submit(); } return false; } }); jQuery('#forget-password').click(function() { jQuery('.login-form').hide(); jQuery('.forget-form').show(); }); jQuery('#back-btn').click(function() { jQuery('.login-form').show(); jQuery('.forget-form').hide(); }); } var handleRegister = function() { function format(state) { if (!state.id) { return state.text; } var $state = $( '<span><img src="../assets/global/img/flags/' + state.element.value.toLowerCase() + '.png" class="img-flag" /> ' + state.text + '</span>' ); return $state; } if (jQuery().select2 && $('#country_list').size() > 0) { $("#country_list").select2({ placeholder: '<i class="fa fa-map-marker"></i> Select a Country', templateResult: format, templateSelection: format, width: 'auto', escapeMarkup: function(m) { return m; } }); $('#country_list').change(function() { $('.register-form').validate().element($(this)); //revalidate the chosen dropdown value and show error or success message for the input }); } $('.register-form').validate({ errorElement: 'span', //default input error message container errorClass: 'help-block', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { fullname: { required: true }, email: { required: true, email: true }, address: { required: true }, city: { required: true }, country: { required: true }, username: { required: true }, password: { required: true }, rpassword: { equalTo: "#register_password" }, tnc: { required: true } }, messages: { // custom messages for radio buttons and checkboxes tnc: { required: "Please accept TNC first." } }, invalidHandler: function(event, validator) { //display error alert on form submit }, highlight: function(element) { // hightlight error inputs $(element) .closest('.form-group').addClass('has-error'); // set error class to the control group }, success: function(label) { label.closest('.form-group').removeClass('has-error'); label.remove(); }, errorPlacement: function(error, element) { if (element.attr("name") == "tnc") { // insert checkbox errors after the container error.insertAfter($('#register_tnc_error')); } else if (element.closest('.input-icon').size() === 1) { error.insertAfter(element.closest('.input-icon')); } else { error.insertAfter(element); } }, submitHandler: function(form) { form.submit(); } }); $('.register-form input').keypress(function(e) { if (e.which == 13) { if ($('.register-form').validate().form()) { $('.register-form').submit(); } return false; } }); jQuery('#register-btn').click(function() { jQuery('.login-form').hide(); jQuery('.register-form').show(); }); jQuery('#register-back-btn').click(function() { jQuery('.login-form').show(); jQuery('.register-form').hide(); }); } return { //main function to initiate the module init: function() { handleLogin(); handleForgetPassword(); handleRegister(); } }; }(); jQuery(document).ready(function() { Login.init(); });帮我分析一下有没有漏洞
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值