JS comprehension (self-use)

Source: Internet
Author: User

1. Single-choice button judgment refers to understanding it as a button group, which is similar to multi-choice box judgment.

// Select one of the selected buttons
VaR C = 0;
For (VAR I = 0; I <frm. elements. length; I ++ ){
If (FRM. elements [I]. Name = "Q1 "){
If (FRM. elements [I]. Checked)
{
C = C + 1;
Break;
}
}
}
If (C = 0)
{
Alert ("Question 1 is not filled! ");
Return (false );
}
C = 0;

2. You cannot use readonly when determining whether the text box is filled. You cannot use this attribute.

Set the disabled text box to <input type = "text" name = "other1" value = "" disabled>

If (! FRM. other5.disabled & frm. other5.value = '')
{
Alert ('question 5: no input! ');
FRM. other5.focus ();
Return false;
}

3. Click the read-only or invalid button to change

Button <input type = "checkbox" name = "Q3 []" value = "E" onclick = "other3.disabled =! Other3.disabled; other3.value = ''">

Text Box <input type = "text" name = "other3" disabled>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.