What are the js issues on the login interface?

Source: Internet
Author: User
What are the js issues on the login interface? Log on to the background system. if the form does not meet js requirements, the js prompts an error. if it is correct, go to php login data verification,

As a result, I made a form without filling anything. js must prompt an error, but I will jump directly to the php page.

I just don't know how to block form action submission when js verification fails?

----------------------------

I used onsubmit,
 


But I don't know how to do it?


Reply to discussion (solution)

Do not use onsubmit events

Write a button as needed. when you click it, the system will detect that the system is qualified. if $ ("form"). submit () is unqualified, the system will prompt that the system is unqualified.

Write verification in check ().

Write a function in js for verification and pass it to php.

Return false in check;

Return false ??

Do not use onsubmit events

Write a button as needed. when you click it, the system will detect that the system is qualified. if $ ("form"). submit () is unqualified, the system will prompt that the system is unqualified.

What if I press enter to submit?


Do not use onsubmit events

Write a button as needed. when you click it, the system will detect that the system is qualified. if $ ("form"). submit () is unqualified, the system will prompt that the system is unqualified.

What if I press enter to submit?

Can I add a detection button to the input in the form to submit if I press enter?

Write the verification method in the check () event of JS.
For example
Function check (){
If (account = ''){
Alert ("account cannot be blank ");
Return false;
}
Return true;
}
If the verification fails, return false is required. if not, the form will be submitted.
Return true can be used or not.



Do not use onsubmit events

Write a button as needed. when you click it, the system will detect that the system is qualified. if $ ("form"). submit () is unqualified, the system will prompt that the system is unqualified.

What if I press enter to submit?

Can I add a detection button to the input in the form to submit if I press enter?
If there are many inputs, each event can have an onkeypress event. Therefore, it is better to return an onsubmit event and false is enough.




Do not use onsubmit events

Write a button as needed. when you click it, the system will detect that the system is qualified. if $ ("form"). submit () is unqualified, the system will prompt that the system is unqualified.

What if I press enter to submit?

Can I add a detection button to the input in the form to submit if I press enter?
If there are many inputs, each event can have an onkeypress event. Therefore, it is better to return an onsubmit event and false is enough.

Education

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.