开发者

A help needed in java script [closed]

开发者 https://www.devze.com 2022-12-23 16:12 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly br开发者_如何学运维oad, or rhetorical andcannot be reasonably answered in its current for
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly br开发者_如何学运维oad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

i need to write a code to validate password the user enters if he/she enters the right one then i need to display the image which suggests the password as right or in the either case i need to display the cross image...so how can i do that using java script????


You can use a regular expression to validate the password syntax. If you want to check whether the password is valid one or not then you have to use a server side etechnology and match against your database.


Do you wish to validate the password in Javascript? If you are using AJAX, you need to parse the response and set the image's src using javascript.


Well you will need to create a a hidden DIV or a 1x1 transparent pixel image in the page, on the form submit call your javascript function to validate the password. If the password is correct, then change the img src property of your 1x1 pixel to the image you want to show, if it is incorrect then change the img src property using javascript to a cross sign. Same approach you can take to manipulate the innerHTML property of a div to add/remove your image. Hope that helps, let me know if you need an example.


If you want to validate form input using javascript - you could use an external javascript library to validate form input like this jquery plugin - saves a lot of time than writing your own code. However bear in mind that javascript validation should not be your only form of validation. Perform a server sided check as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消