简体   繁体   English

我是 JavaScript 的新手。 请帮我进行 javascript 验证

[英]I am new to JavaScript. please help me for javascript validation

我需要在 textarea 中进行验证,该文本必须以数字开头,然后在正则表达式的帮助下以 '\\' 开头,例如 javascript 中的 '5\\' 任何人都可以帮助我吗?

You need to hook up a user event (such as blur, a field dropping input focus) to a function that validates the content to your regex.您需要将用户事件(例如模糊、放置输入焦点的字段)连接到验证正则表达式内容的函数。

Example with jQuery: jQuery 示例:

$(".text-field").on("blur", function () {
    var test = /^\d/\/.test($(this).value());
    if (!test) {
        alert("invalid text");
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我是编程新手以及 javascript,所以请帮我处理循环 - I am new in programing as well as in javascript so please help me with loop Javascript新手。 有人可以帮我调试我的程序吗? - New to Javascript. Can someone help me debug my program? 无法用JavaScript替换文本。 请帮忙 - Trouble replacing text with JavaScript. Please help 我无法通过用户使用 html 和 javascript 输入给定日期来找到以前的日期。 你能帮帮我吗 - I'm unable to find a previous date by inputing a given date by a user using html and javascript. Can you please help me out 请帮助我。我是 JavaScript 的初学者 - Please help me .I'm a beginner at JavaScript 在javascript中的“ this”语句上挠头。 任何人请帮助 - scratching my head over “this” statement in javascript. anyone help please 我正在使用这个javascript来“未定义”。 为什么? - I am geting “undefined” with this javascript. Why? 我正在尝试使用JavaScript创建一个计算器。 - I am trying to create a calculator with javascript. javascript我怎么解决这个问题,请帮帮我 - How can i solve this problem in javascript, please help me JavaScript新手。 我试图将单选按钮的值作为javascript函数中对象的名称传递 - new to javascript. I am trying to pass the value of a radio button as the name of an object in a javascript function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM