简体   繁体   English

我正在尝试使用JavaScript验证用户输入。 我想验证用户是否正确输入了他们的课程名称

[英]I am trying to validate user input using JavaScript. I would like to validate that the user has input their the title of their course correctly

Sell/Trade Textbook Form - 'Course Title' Field 买卖教科书表格-“课程名称”字段

  • Check that it begins with a letter(s), followed by a number(s), followed by a space, and followed by a letter(s) or number(s). 检查它是否以字母开头,然后是数字,空格,字母或数字开头。

    1. Example: IS448 Markup and Scripting Languages 示例:IS448标记和脚本语言
    2. Example: CTP150 Computer Science 1 示例:CTP150计算机科学1

This is what I have so far: 这是我到目前为止的内容:

(/^([a-zA-Z0-9]+)\s([a-zA-Z0-9]*)$/);

but it is not working. 但它不起作用。 Any suggestions? 有什么建议么?

尝试这个:

^[A-Za-z]+[0-9]+\s[A-Za-z0-9\s]+$

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM