Java脚本警报消息 [英] java script alert message

查看:55
本文介绍了Java脚本警报消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨gud evng,

我有两个文本字段作为应用程序名称和日期字段.给定的id是app_name,f_date_a.我的疑问是我想在脚本中保留对这两个字段的验证.我已经保存了验证代码如下.

Hi gud evng,

I have two text fields as application name and date field.The id''s given for those are app_name,f_date_a.My doubt is i want to keep the validations for those two fields in the script.I have already kept the code for validation as below.

var app_name = document.getElementById('app_name').value;
                var date = document.getElementById('f_date_a').value;
                if(app_name==0)
                {
                    alert('Select Any One Application !!');
                    document.getElementById(app_name);
                    return false;
                }
                else if(date=='')
                {
                    alert('Date Mandatory !!');
                    document.getElementById(date);
                    return false;
                }
                else
                {
                    return true;
                }


它正在显示应用程序名称的警报消息.对于日期,它也会显示该消息.但是,单击确定"按钮后,它不是在等待日期,而是在直接提交.您能给我解决方案吗?我的代码.


It is displaying the alert message for application name.For date also it is displaying the message.But after clicking on the ok button it is not waiting for the date directly it is submitting.Can you give me the solution is there any thing wrong in my code.

推荐答案

在确定"按钮上使用此按钮
clientclick ="return yourfunctionname();"
Use this on OK Button
clientclick="return yourfunctionname();"


您的代码不会错-只是不符合要求.

您正在返回原始表单并将数据发送到服务器-对吗?您需要获取消息的返回码并对此做出反应.另外,您还有一个从验证返回的布尔值-您也可以对此做出反应.

仅当验证返回true时,才尝试发送数据.
Your code can''t be wrong - it just doesn''t meet the requirement.

You''re returning to the original form and sending the data to the server - right? You need to get the return code of your message and react on that. Also you have a boolean value that is returned from your validation - that''s also something you can react on.

Try to send the data only when validation returned true.


这篇关于Java脚本警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆