Академический Документы
Профессиональный Документы
Культура Документы
<form name="mf">
<input type="text" name="input_field" >
<input type="button" value="submit" onclick="do_things( );">
</form>
<script>
function do_things( ) {
str = document.mf.input_field.value;
alert(str.split("a").length - 1);
}
</script>
<form name="mf">
<input type="text" name="input_field" >
<input type="button" value="submit" onclick="do_things( );">
</form>
<script>
function do_things( ) {
str = document.mf.input_field.value;
count = 0;
for (let char of str)
{
if ('0123456789'.includes(char))
{
count++;
}
}
alert(count);
}
</script>
<form name="mf">
<input type="text" name="input_field" >
<input type="button" value="submit" onclick="do_things( );">
</form>
<script>
function do_things( ) {
str = document.mf.input_field.value;
if (str.split('').reverse().join('') == str)
{
alert('palindrome');
} else
{
alert('not a palindrome');
}
}
</script>
<script>
function do_things( ) {
str = document.mf.input_field.value;
words = str.split(" ").sort((f_el,s_el)=>s_el.length - f_el.length);
max_len = words[0].length;
for (let word of words)
{
if (word.length == max_len)
{
document.write(word + "<br>");
}
}
}
</script>
<form name="mf">
<input type="text" name="input_field1" >
<input type="text" name="input_field2" >
<input type="button" value="submit" onclick="do_things( );">
</form>
<script>
function do_things( ) {
input1 = document.mf.input_field1.value.split('-');
input2 = document.mf.input_field2.value.split('-');
date1 = new Date(input1[2], input1[1], input1[0]);
date2 = new Date(input2[2], input2[1], input2[0]);
alert(Math.abs(date1-date2))
}
</script>