javascript验证弹出错误

时间:2017-11-29 13:49:48

标签: javascript jquery html validation alert

我目前正在使用validationMsgs(),如下所示我的common.js

function validationMsgs(message, title, button) {
navigator.notification.alert(
       message,
       function () { },
       title,
       button
    );
}

在我的calculator.html中,我想在表单id,

下验证此字段
<form id="converter"> 
<input type="text" name="from" id="from" value="abc" required>
<input type="number" name="rate" id="rate" value="100" required/>

在我的calculator.js中,它与calculator.html相关联,我包含了这些代码

$("#btnconvert").bind("click", function () {
        if ($("#converter").valid()) { 
            //Do i have to add a if condition here if i want to proceed to next page?
        }
$("#converter").validate({
        messages: {
            from: "this field is required",
            rate: "this field is required".

    },
       rules: {
        rate: {
           min: 1
        },
       },
    focusInvalid: false,
    submitHandler: function () {
        return false;
    },
    errorPlacement: function (error, element) {
        error.appendTo(element.parent().parent().after());
    },
});

我不知道放在&#34;的条件是什么? if($(&#34; #reverter&#34;)。valid()){&#34;是否需要提出条件? 提前谢谢!

0 个答案:

没有答案