- Be able to check pattern:
For example, p = uName.search(/^[A-Z][a-z]+$/)
- Be able to get user's input:
- Input from a
prompt
function
- Input from
text box
of a form
:
var uName = document.getElementById("uName").value;
- How to send html's form input to javaScript?
<input type="button" id="done" value="DONE"
onclick = "check()" />
- Keep checking a correct format:
- A
while
loop for prompt
function
- A checking function with
if
statement and return false;
when the format is incorrect. For example,
p = variable.search(/...../);
if (p != 0) {
alert("Enter ...., not .....");
return false;
}
- Be able to create a function to do calculations
- Be able to block user entering results
<input type="text" name="...", id="..." size ="6"
onfocus = "this.blur();"/>
- Be able to write a result in the form box by an assignment statement:
document.getElementById("....").value = ....